]> source.dussan.org Git - nextcloud-server.git/commitdiff
refactor: Inject IRootFolder backport/46124/stable28 48744/head
authorChristopher Ng <chrng8@gmail.com>
Thu, 27 Jun 2024 18:40:05 +0000 (11:40 -0700)
committerChristopher Ng <chrng8@gmail.com>
Wed, 16 Oct 2024 23:10:09 +0000 (16:10 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files/lib/Service/OwnershipTransferService.php

index 16300cba80ee54e0766609bae11ac1d96b64d033..283a49932f723381af9862aef2e67b6706b5582e 100644 (file)
@@ -69,6 +69,7 @@ class OwnershipTransferService {
                private IMountManager $mountManager,
                private IUserMountCache $userMountCache,
                private IUserManager $userManager,
+               private IRootFolder $rootFolder,
        ) {
                $this->encryptionManager = $encryptionManager;
        }
@@ -109,8 +110,8 @@ class OwnershipTransferService {
                // 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 @@ class OwnershipTransferService {
        ):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 @@ class OwnershipTransferService {
                                                } 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);
                                                }