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:
@@ -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"})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user