Skip to content

Commit

Permalink
Merge pull request #48746 from nextcloud/backport/46124/stable30
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Oct 29, 2024
2 parents 7bd791f + 6090985 commit a9dd34a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function __construct(
private IUserMountCache $userMountCache,
private IUserManager $userManager,
private IFactory $l10nFactory,
private IRootFolder $rootFolder,
) {
$this->encryptionManager = $encryptionManager;
}
Expand Down Expand Up @@ -85,8 +86,10 @@ public function transfer(
// Requesting the user folder will set it up if the user hasn't logged in before
// We need a setupFS for the full filesystem setup before as otherwise we will just return
// 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($destinationUser->getUID());
$this->rootFolder->getUserFolder($sourceUser->getUID());
$this->rootFolder->getUserFolder($destinationUser->getUID());
Filesystem::initMountPoints($sourceUid);
Filesystem::initMountPoints($destinationUid);

Expand Down Expand Up @@ -416,7 +419,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 @@ -455,7 +457,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);
Expand Down

0 comments on commit a9dd34a

Please sign in to comment.