From 92432a2cda909caea1822971a594918714d68671 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 27 Jun 2024 11:40:05 -0700 Subject: [PATCH] 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 146c761d6b867..90d0135535871 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -47,6 +47,7 @@ public function __construct( private IUserMountCache $userMountCache, private IUserManager $userManager, private IFactory $l10nFactory, + private IRootFolder $rootFolder, ) { $this->encryptionManager = $encryptionManager; } @@ -87,8 +88,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); @@ -395,7 +396,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 { @@ -434,7 +434,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(); } $share->setNodeId($newNodeId);