Skip to content

[stable31] fix: Transfer ownership with S3 as primary - #52185

Merged
artonge merged 1 commit into
stable31from
backport/51020/stable31
Apr 17, 2025
Merged

[stable31] fix: Transfer ownership with S3 as primary#52185
artonge merged 1 commit into
stable31from
backport/51020/stable31

Conversation

@backportbot

Copy link
Copy Markdown

Backport of PR #51020

@backportbotbackportbotBot added bug 3. to review Waiting for reviews feature: filesystem php Pull requests that update Php code labels Apr 14, 2025
@backportbotbackportbotBot added this to the Nextcloud 31.0.4 milestone Apr 14, 2025
This was referenced Apr 15, 2025
@artonge
artongeforce-pushed the backport/51020/stable31 branch from ae9bf70 to e5c035dCompareApril 15, 2025 10:04
When using S3 as primary storage, transferring ownership with the `--move` option fail with the following error:
`SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8-45b963397aa40d4a0063e0d85e4fe7a1' for key 'fs_storage_path_hash'`
The `--move` option moves the entire home folder from one account to another.
The error means that the move failed because the destination folder already exist in `oc_filecache`.
- With S3 as primary storage, folders only exists as entries in `oc_filecache`.
- With S3 as primary storage, `moveFromStorage(...)` only moves the cache entry, as nothing needs to be moved on disk. This cache move does not delete potentially pre-existing destination folder.
- With Local storage, `moveFromStorage(...)` calls `rename(...)` which delete pre-existing folder.
- `transfer(...)`: https://github.com/nextcloud/server/blob/687a4d9ac7fcdbd935f81a0def567a1092306f7a/apps/files/lib/Service/OwnershipTransferService.php#L112
- `oneTimeUserSetup(...)`: https://github.com/nextcloud/server/blob/687a4d9ac7fcdbd935f81a0def567a1092306f7a/lib/private/Files/SetupManager.php#L261-L262
- `mkdir(...)`: https://github.com/nextcloud/server/blob/687a4d9ac7fcdbd935f81a0def567a1092306f7a/lib/private/Files/ObjectStore/ObjectStoreStorage.php#L91-L135
- `moveFromStorage(...)`: https://github.com/nextcloud/server/blob/687a4d9ac7fcdbd935f81a0def567a1092306f7a/lib/private/Files/ObjectStore/ObjectStoreStorage.php#L635-L636
Delete pre-existing folder in `moveFromStorage(...)`
Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge
artongeforce-pushed the backport/51020/stable31 branch from e5c035d to 27ed921CompareApril 16, 2025 08:19
@AltahrimAltahrim mentioned this pull request Apr 17, 2025
18 tasks
@artonge
artonge merged commit e51e64e into stable31Apr 17, 2025
@artonge
artonge deleted the backport/51020/stable31 branch April 17, 2025 09:38
@blizzzblizzz mentioned this pull request May 5, 2025
10 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbugfeature: filesystemphpPull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@artonge@come-nc