Properly handle directory read errors

This commit is contained in:
raul 2024-06-18 09:04:05 +02:00
parent 7078068435
commit 2d9176ef14
1 changed files with 6 additions and 1 deletions

View File

@ -142,7 +142,12 @@ func listFiles(conn net.Conn, rpath string) {
if rpath == "/" { if rpath == "/" {
path = "/" path = "/"
} }
list, _ := os.ReadDir(path) list, err := os.ReadDir(path)
if err != nil {
e := fmt.Sprint(err)
sendMessage(Response{Successful: false, Message: e}, conn)
return
}
newList := FileList{} newList := FileList{}
for _, v := range list { for _, v := range list {