Refactor file download URL construction to use ApiClient's base URL and ensure consistent remote path for user files

This commit is contained in:
Leon Bösche
2026-01-09 23:01:11 +01:00
parent d20840f4a6
commit aac6d2eb46
4 changed files with 10 additions and 5 deletions

View File

@@ -1234,7 +1234,8 @@ func deleteUserFileHandler(w http.ResponseWriter, r *http.Request, db *database.
// Delete from Nextcloud if configured
if storageClient != nil {
rel := strings.TrimPrefix(req.Path, "/")
remotePath := path.Join("/user", userID.String(), rel)
// Keep remote user workspace path consistent with uploads: "/users/<userID>/<rel>"
remotePath := path.Join("/users", userID.String(), rel)
if err := storageClient.Delete(r.Context(), remotePath); err != nil {
errors.LogError(r, err, "Failed to delete from Nextcloud (continuing anyway)")
}
@@ -1314,7 +1315,8 @@ func downloadUserFileHandler(w http.ResponseWriter, r *http.Request, db *databas
// Try to download from Nextcloud first
if storageClient != nil {
rel := strings.TrimPrefix(filePath, "/")
remotePath := path.Join("/user", userID.String(), rel)
// Keep remote user workspace path consistent with uploads: "/users/<userID>/<rel>"
remotePath := path.Join("/users", userID.String(), rel)
reader, size, err := storageClient.Download(r.Context(), remotePath)
if err == nil {