fix: Transfer ownership with S3 as primary#51020
Merged
Conversation
8858cbe to
50696c5
Compare
come-nc
approved these changes
Feb 27, 2025
Altahrim
approved these changes
Mar 3, 2025
0c73e73 to
cc9966d
Compare
Contributor
Author
|
/backport to stable31 |
Contributor
Author
|
/backport to stable30 |
Contributor
Author
|
/backport to stable29 |
icewind1991
requested changes
Mar 4, 2025
Member
icewind1991
left a comment
There was a problem hiding this comment.
The existing objects will have to be deleted to, not just the cache entries
Contributor
Author
Indeed, that's a concern. Not sure how to best proceed, because in case of a folder, we'll need to get all its children, no? |
susnux
reviewed
Mar 5, 2025
84b07b6 to
b50e03a
Compare
Contributor
Author
I added |
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>
b50e03a to
8fdf2a7
Compare
icewind1991
approved these changes
Apr 14, 2025
This was referenced Apr 14, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
When using S3 as primary storage, transferring ownership with the
--moveoption fail with the following error:SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8-45b963397aa40d4a0063e0d85e4fe7a1' for key 'fs_storage_path_hash'The
--moveoption 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.Might have been introduced by: #26149
Investigation
oc_filecache.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.moveFromStorage(...)callsrename(...)which delete pre-existing folder.S3's
moveFromStorageserver/lib/private/Files/ObjectStore/ObjectStoreStorage.php
Lines 593 to 599 in 373107b
Local's
rename, called bymoveFromStorageserver/lib/private/Files/Storage/Local.php
Lines 346 to 352 in 373107b
Solution
Delete pre-existing folder in
moveFromStorage(...)Does it make sense to have that here? It feels off.
Todo
tests/lib/Files/Storage/StoragesTest.php