Remove unused os import and enforce exclusive use of Nextcloud WebDAV storage in file handlers
This commit is contained in:
@@ -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/<orgId>
|
||||
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/<userID>/<rel>"
|
||||
remotePath := path.Join("/users", userID.String(), rel)
|
||||
|
||||
Reference in New Issue
Block a user