Skip to content

Commit

Permalink
refactor: Inject IRootFolder
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Oct 16, 2024
1 parent 6015330 commit 2ab6536
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function __construct(
private IMountManager $mountManager,
private IUserMountCache $userMountCache,
private IUserManager $userManager,
private IRootFolder $rootFolder,
) {
$this->encryptionManager = $encryptionManager;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 2ab6536

Please sign in to comment.