Refactor filesystem to not be dependent on a server struct

This commit is contained in:
Dane Everitt
2020-09-27 12:24:08 -07:00
parent de30e2fcc9
commit 0f7bb1a371
27 changed files with 1203 additions and 1088 deletions

View File

@@ -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)
}