Skip to content

Commit 7ba52ea

Browse files
committed
refactor: Inject IRootFolder
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 53f0b37 commit 7ba52ea

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function __construct(
5050
private IUserMountCache $userMountCache,
5151
private IUserManager $userManager,
5252
private IFactory $l10nFactory,
53+
private IRootFolder $rootFolder,
5354
) {
5455
$this->encryptionManager = $encryptionManager;
5556
}
@@ -90,8 +91,8 @@ public function transfer(
9091
// a lazy root folder which does not create the destination users folder
9192
\OC_Util::setupFS($sourceUser->getUID());
9293
\OC_Util::setupFS($destinationUser->getUID());
93-
\OC::$server->getUserFolder($sourceUser->getUID());
94-
\OC::$server->getUserFolder($destinationUser->getUID());
94+
$this->rootFolder->getUserFolder($sourceUser->getUID());
95+
$this->rootFolder->getUserFolder($destinationUser->getUID());
9596
Filesystem::initMountPoints($sourceUid);
9697
Filesystem::initMountPoints($destinationUid);
9798

@@ -421,7 +422,6 @@ private function restoreShares(
421422
):void {
422423
$output->writeln('Restoring shares ...');
423424
$progress = new ProgressBar($output, count($shares));
424-
$rootFolder = Server::get(IRootFolder::class);
425425

426426
foreach ($shares as ['share' => $share, 'suffix' => $suffix]) {
427427
try {
@@ -461,7 +461,7 @@ private function restoreShares(
461461
} catch (NotFoundException) {
462462
// ID has changed due to transfer between different storages
463463
// Try to get the new ID from the target path and suffix of the share
464-
$node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
464+
$node = $this->rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
465465
$newNodeId = $node->getId();
466466
$output->writeln('Had to change node id to ' . $newNodeId, OutputInterface::VERBOSITY_VERY_VERBOSE);
467467
}

0 commit comments

Comments
 (0)