From 185cbc83b919455d17b4213ae980945e29c87c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6sche?= Date: Sat, 10 Jan 2026 21:46:16 +0100 Subject: [PATCH] Remove unused os import and enforce exclusive use of Nextcloud WebDAV storage in file handlers --- go_cloud/internal/http/routes.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/go_cloud/internal/http/routes.go b/go_cloud/internal/http/routes.go index 8e81a7c..c39b3a5 100644 --- a/go_cloud/internal/http/routes.go +++ b/go_cloud/internal/http/routes.go @@ -8,7 +8,6 @@ import ( "mime/multipart" "net/http" "net/url" - "os" "path" "path/filepath" "strings" @@ -1063,12 +1062,12 @@ func createOrgFileHandler(w http.ResponseWriter, r *http.Request, db *database.D storedPath = "/" + storedPath } written := int64(len(data)) - + if storageClient == nil { errors.WriteError(w, errors.CodeInternal, "Storage not configured", http.StatusInternalServerError) return } - + // Build remote path under /orgs/ rel := strings.TrimPrefix(storedPath, "/") remotePath := path.Join("/orgs", orgID.String(), rel) @@ -1213,13 +1212,13 @@ func createUserFileHandler(w http.ResponseWriter, r *http.Request, db *database. } written := int64(len(data)) fmt.Printf("[DEBUG] Upload: user=%s, file=%s, size=%d, path=%s\n", userID.String(), header.Filename, len(data), storedPath) - + // ONLY use Nextcloud WebDAV storage if storageClient == nil { errors.WriteError(w, errors.CodeInternal, "Storage not configured", http.StatusInternalServerError) return } - + rel := strings.TrimPrefix(storedPath, "/") remotePath := path.Join("/users", userID.String(), rel) fmt.Printf("[DEBUG] Uploading to WebDAV: %s\n", remotePath) @@ -1339,7 +1338,7 @@ func downloadOrgFileHandler(w http.ResponseWriter, r *http.Request, db *database errors.WriteError(w, errors.CodeInternal, "Storage not configured", http.StatusInternalServerError) return } - + rel := strings.TrimPrefix(filePath, "/") remotePath := path.Join("/orgs", orgID.String(), rel) @@ -1396,7 +1395,7 @@ func downloadUserFileHandler(w http.ResponseWriter, r *http.Request, db *databas errors.WriteError(w, errors.CodeInternal, "Storage not configured", http.StatusInternalServerError) return } - + rel := strings.TrimPrefix(filePath, "/") // Keep remote user workspace path consistent with uploads: "/users//" remotePath := path.Join("/users", userID.String(), rel)