Skip to content

Commit a9dd34a

Browse files
authored
Merge pull request #48746 from nextcloud/backport/46124/stable30
2 parents 7bd791f + 6090985 commit a9dd34a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function __construct(
4747
private IUserMountCache $userMountCache,
4848
private IUserManager $userManager,
4949
private IFactory $l10nFactory,
50+
private IRootFolder $rootFolder,
5051
) {
5152
$this->encryptionManager = $encryptionManager;
5253
}
@@ -85,8 +86,10 @@ public function transfer(
8586
// Requesting the user folder will set it up if the user hasn't logged in before
8687
// We need a setupFS for the full filesystem setup before as otherwise we will just return
8788
// a lazy root folder which does not create the destination users folder
89+
\OC_Util::setupFS($sourceUser->getUID());
8890
\OC_Util::setupFS($destinationUser->getUID());
89-
\OC::$server->getUserFolder($destinationUser->getUID());
91+
$this->rootFolder->getUserFolder($sourceUser->getUID());
92+
$this->rootFolder->getUserFolder($destinationUser->getUID());
9093
Filesystem::initMountPoints($sourceUid);
9194
Filesystem::initMountPoints($destinationUid);
9295

@@ -416,7 +419,6 @@ private function restoreShares(
416419
):void {
417420
$output->writeln("Restoring shares ...");
418421
$progress = new ProgressBar($output, count($shares));
419-
$rootFolder = \OCP\Server::get(IRootFolder::class);
420422

421423
foreach ($shares as ['share' => $share, 'suffix' => $suffix]) {
422424
try {
@@ -455,7 +457,7 @@ private function restoreShares(
455457
} catch (\OCP\Files\NotFoundException) {
456458
// ID has changed due to transfer between different storages
457459
// Try to get the new ID from the target path and suffix of the share
458-
$node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
460+
$node = $this->rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
459461
$newNodeId = $node->getId();
460462
}
461463
$share->setNodeId($newNodeId);

0 commit comments

Comments
 (0)