From b14e53666b24873fd7fa66aa3b2cc5fa4f5142d3 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Tue, 25 Jun 2024 16:18:30 -0700 Subject: [PATCH 1/2] fix: Fix "Unknown path" error when source user `files` folder has not been initialized Signed-off-by: Christopher Ng --- apps/files/lib/Service/OwnershipTransferService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 1461ee1400e09..16300cba80ee5 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -107,7 +107,9 @@ public function transfer( // 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($sourceUser->getUID()); \OC::$server->getUserFolder($destinationUser->getUID()); Filesystem::initMountPoints($sourceUid); Filesystem::initMountPoints($destinationUid); From 0f9cf04537ecdd5d0831365e83850c95ac002547 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 27 Jun 2024 11:40:05 -0700 Subject: [PATCH 2/2] refactor: Inject IRootFolder Signed-off-by: Christopher Ng --- apps/files/lib/Service/OwnershipTransferService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 16300cba80ee5..283a49932f723 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -69,6 +69,7 @@ public function __construct( private IMountManager $mountManager, private IUserMountCache $userMountCache, private IUserManager $userManager, + private IRootFolder $rootFolder, ) { $this->encryptionManager = $encryptionManager; } @@ -109,8 +110,8 @@ public function transfer( // 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($sourceUser->getUID()); - \OC::$server->getUserFolder($destinationUser->getUID()); + $this->rootFolder->getUserFolder($sourceUser->getUID()); + $this->rootFolder->getUserFolder($destinationUser->getUID()); Filesystem::initMountPoints($sourceUid); Filesystem::initMountPoints($destinationUid); @@ -437,7 +438,6 @@ private function restoreShares( ):void { $output->writeln("Restoring shares ..."); $progress = new ProgressBar($output, count($shares)); - $rootFolder = \OCP\Server::get(IRootFolder::class); foreach ($shares as ['share' => $share, 'suffix' => $suffix]) { try { @@ -477,7 +477,7 @@ private function restoreShares( } catch (\OCP\Files\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); }