diff options
author | Pytal <24800714+Pytal@users.noreply.github.com> | 2024-10-16 16:06:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-16 16:06:23 -0700 |
commit | 94692cd57b93de913d79e76816d6a371c6ebe7e2 (patch) | |
tree | 3909d5ffbc71a62ff5abb1a858e82b7290f8e4a2 | |
parent | 923ce7b93727edaba4509f605a270bc619479640 (diff) | |
parent | 7ba52eae35ae40efe05775a11c2b1a278754fdf9 (diff) | |
download | nextcloud-server-94692cd57b93de913d79e76816d6a371c6ebe7e2.tar.gz nextcloud-server-94692cd57b93de913d79e76816d6a371c6ebe7e2.zip |
Merge pull request #46124 from nextcloud/fix/ownership-transfer-source-user-files
fix: Fix "Unknown path" error when source user `files` folder has not been initialized
-rw-r--r-- | apps/files/lib/Service/OwnershipTransferService.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 2b06d18efcf..b5ae26d8b1f 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -50,6 +50,7 @@ class OwnershipTransferService { private IUserMountCache $userMountCache, private IUserManager $userManager, private IFactory $l10nFactory, + private IRootFolder $rootFolder, ) { $this->encryptionManager = $encryptionManager; } @@ -88,8 +89,10 @@ class OwnershipTransferService { // Requesting the user folder will set it up if the user hasn't logged in before // We need a setupFS for the full filesystem setup before as otherwise we will just return // a lazy root folder which does not create the destination users folder + \OC_Util::setupFS($sourceUser->getUID()); \OC_Util::setupFS($destinationUser->getUID()); - \OC::$server->getUserFolder($destinationUser->getUID()); + $this->rootFolder->getUserFolder($sourceUser->getUID()); + $this->rootFolder->getUserFolder($destinationUser->getUID()); Filesystem::initMountPoints($sourceUid); Filesystem::initMountPoints($destinationUid); @@ -419,7 +422,6 @@ class OwnershipTransferService { ):void { $output->writeln('Restoring shares ...'); $progress = new ProgressBar($output, count($shares)); - $rootFolder = Server::get(IRootFolder::class); foreach ($shares as ['share' => $share, 'suffix' => $suffix]) { try { @@ -459,7 +461,7 @@ class OwnershipTransferService { } catch (NotFoundException) { // ID has changed due to transfer between different storages // Try to get the new ID from the target path and suffix of the share - $node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix)); + $node = $this->rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix)); $newNodeId = $node->getId(); $output->writeln('Had to change node id to ' . $newNodeId, OutputInterface::VERBOSITY_VERY_VERBOSE); } |