Refactor filesystem to not be dependent on a server struct
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pterodactyl/wings/server"
|
||||
"github.com/pterodactyl/wings/server/filesystem"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -105,9 +106,9 @@ func (e *RequestError) AbortFilesystemError(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(e.Err, server.ErrNotEnoughDiskSpace) {
|
||||
if errors.Is(e.Err, filesystem.ErrNotEnoughDiskSpace) {
|
||||
c.AbortWithStatusJSON(http.StatusConflict, gin.H{
|
||||
"error": server.ErrNotEnoughDiskSpace.Error(),
|
||||
"error": "There is not enough disk space available to perform that action.",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -126,6 +127,13 @@ func (e *RequestError) AbortFilesystemError(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasSuffix(e.Err.Error(), "file name too long") {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
|
||||
"error": "Cannot perform that action: file name is too long.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
e.AbortWithServerError(c)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user