From 601533036086d0ce38bf4506ad308d4d1543af3d 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 b6e0d437b4ae4..15110e4349f03 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 2ab6536322a21a363352a4a56a8442e60600ad42 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 15110e4349f03..75f67767ac919 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); }