Return a 404 when the directory does not exist

This commit is contained in:
Dane Everitt 2020-07-18 10:16:40 -07:00
parent 21303dc517
commit 115131575d
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -78,6 +78,13 @@ func getServerListDirectory(c *gin.Context) {
stats, err := s.Filesystem.ListDirectory(d)
if err != nil {
if err.Error() == "readdirent: not a directory" {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
"error": "The requested directory does not exist.",
})
return
}
TrackedServerError(err, s).AbortWithServerError(c)
return
}