From 5658dc70f42318850a0e4fd2b5efdb975ba8b8bb Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 29 Jan 2026 20:20:39 -0500 Subject: [PATCH] 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 --- internal/handlers/library.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/handlers/library.go b/internal/handlers/library.go index 9282fda..94241e0 100644 --- a/internal/handlers/library.go +++ b/internal/handlers/library.go @@ -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"}) }