Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Always create user directory when transfering files to new users #37625

Merged
merged 1 commit into from
Apr 11, 2023

Conversation

juliusknorr
Copy link
Member

@juliusknorr juliusknorr commented Apr 6, 2023

#30953 was originally there to fix this however with the partial file system setup in 24 we no longer setup the full file system when requesting the user root. This means that the call for getUserFolder does not create the folder but returns a LazyRootFolder instead. However since further handling of transfer ownership does not go through the Nodes API the actual RootFolder handling is never triggered. Explicitly calling for a full FS setup fixes this.

Steps to reproduce:

  • Create a new user that has never logged in
  • call occ files:transfer-ownership admin newuser

Fixes #35111

Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliusknorr juliusknorr added bug 3. to review Waiting for reviews labels Apr 6, 2023
@juliusknorr
Copy link
Member Author

/backport to stable26

@juliusknorr
Copy link
Member Author

/backport to stable25

@juliusknorr
Copy link
Member Author

/backport to stable24

Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but didnt test

@juliusknorr
Copy link
Member Author

Failure unrelated

@juliusknorr juliusknorr merged commit cd44ee2 into master Apr 11, 2023
@juliusknorr juliusknorr deleted the bugfix/noid/transfer-file-new-user branch April 11, 2023 05:57
artonge added a commit that referenced this pull request Feb 25, 2025
This PR currently implements solution n°1.

## Issue

When using S3 as primary storage, transferring ownership with the `--move` option fail.
The `--move` option moves the entire home folder from one account to another.

## Investigation

1. With S3 as primary storage, an entry in `oc_filecache` is created when calling `mkdir(...)`. This is because folders only exists in the cache when using S3 as primary.
2. Since #37625, we are calling `setupFS(..)` for the destination user, which calls `mkdir(...)`, which create the entry in `oc_filecache`.
3. With S3 as primary, `moveFromStorage(...)` will only move the teh cache entry as nothing needs to be moved on disk. This cache move does not delete potentially pre-existing destination 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

## Solutions

1. Do not create a cache entry during `mkdir(...)`
2. Delete pre-existing folder in `moveFromStorage(...)`
3. ?

Signed-off-by: Louis Chemineau <louis@chmn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: occ transfer ownership of files will fail if the new created user has never been logged in
3 participants