fix: correct folder path validation error handling in AddLibraryFolder

- Fix scoping issue with err variable in os.Stat check
- Properly check for non-existent vs inaccessible folders
- Use reassignment (=) instead of declaration (:=) since err already declared
This commit is contained in:
2026-01-29 20:20:39 -05:00
parent 59b32f4827
commit 5658dc70f4
+4 -3
View File
@@ -175,10 +175,11 @@ func (h *LibraryHandler) AddLibraryFolder(c echo.Context) error {
}
// Validate that folder path exists and is accessible
if _, err := os.Stat(req.FolderPath); os.IsNotExist(err) {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "folder path does not exist"})
}
_, err = os.Stat(req.FolderPath)
if err != nil {
if os.IsNotExist(err) {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "folder path does not exist"})
}
return c.JSON(http.StatusBadRequest, map[string]string{"error": "folder is not accessible"})
}