Refactor moveUserFileHandler to store user files directly in WebDAV root, removing unnecessary path prefix
This commit is contained in:
@@ -1640,10 +1640,9 @@ func moveUserFileHandler(w http.ResponseWriter, r *http.Request, db *database.DB
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
errors.LogError(r, err, "Failed to get user WebDAV client (continuing with database operation)")
|
errors.LogError(r, err, "Failed to get user WebDAV client (continuing with database operation)")
|
||||||
} else {
|
} else {
|
||||||
sourceRel := strings.TrimPrefix(req.SourcePath, "/")
|
// User files are stored directly in the user's WebDAV root (no /users/{id} prefix)
|
||||||
sourcePath := path.Join("/users", userID.String(), sourceRel)
|
sourcePath := "/" + strings.TrimPrefix(req.SourcePath, "/")
|
||||||
targetRel := strings.TrimPrefix(newPath, "/")
|
targetPath := "/" + strings.TrimPrefix(newPath, "/")
|
||||||
targetPath := path.Join("/users", userID.String(), targetRel)
|
|
||||||
if err := storageClient.Move(r.Context(), sourcePath, targetPath); err != nil {
|
if err := storageClient.Move(r.Context(), sourcePath, targetPath); err != nil {
|
||||||
errors.LogError(r, err, "Failed to move in Nextcloud (continuing with database operation)")
|
errors.LogError(r, err, "Failed to move in Nextcloud (continuing with database operation)")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user