Better handle readdirent errors

This commit is contained in:
Matthew Penner
2020-09-24 21:48:59 -06:00
parent 897c4869de
commit 1a3ba9efca
2 changed files with 2 additions and 2 deletions

View File

@@ -82,7 +82,7 @@ func getServerListDirectory(c *gin.Context) {
stats, err := s.Filesystem.ListDirectory(d)
if err != nil {
if err.Error() == "readdirent: not a directory" {
if e, ok := err.(*os.SyscallError); ok && e.Syscall == "readdirent" {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
"error": "The requested directory does not exist.",
})