Return a nicer error if the file name is too long; closes pterodactyl/panel#2403

This commit is contained in:
Dane Everitt 2020-09-24 20:02:42 -07:00
parent f0a4efb242
commit 897c4869de
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -156,6 +156,13 @@ func putServerRenameFiles(c *gin.Context) {
return return
} }
if strings.HasSuffix(err.Error(), "file name too long") {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "Cannot move or rename file, name is too long.",
})
return
}
TrackedServerError(err, s).AbortWithServerError(c) TrackedServerError(err, s).AbortWithServerError(c)
return return
} }
@ -254,6 +261,13 @@ func postServerWriteFile(c *gin.Context) {
return return
} }
if strings.HasSuffix(err.Error(), "file name too long") {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "Cannot move or rename file, name is too long.",
})
return
}
TrackedServerError(err, s).AbortWithServerError(c) TrackedServerError(err, s).AbortWithServerError(c)
return return
} }