From 115131575d2c64bd2085b89841d09dd9e1a025a7 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 18 Jul 2020 10:16:40 -0700 Subject: [PATCH] Return a 404 when the directory does not exist --- router/router_server_files.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/router/router_server_files.go b/router/router_server_files.go index a7db31e..4559e0c 100644 --- a/router/router_server_files.go +++ b/router/router_server_files.go @@ -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 }