Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Transfer incomming shares first, do not delete non-migratable ones
Canceling the previous add of deletion of invalid shares in
 transferownership because in some cases it deletes valid reshares, if
 incoming shares are not transfered on purpose.
Inverting the order of transfer between incoming and outgoing so that
 reshare can be migrated when incoming shares are transfered.

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc authored and backportbot[bot] committed Dec 20, 2024
commit 58b64ad5672098334fbb6cdffec8efbbab0abb80
23 changes: 10 additions & 13 deletions apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,6 @@ public function transfer(
$output
);

$destinationPath = $finalTarget . '/' . $path;
// restore the shares
$this->restoreShares(
$sourceUid,
$destinationUid,
$destinationPath,
$shares,
$output
);

// transfer the incoming shares
if ($transferIncomingShares === true) {
$sourceShares = $this->collectIncomingShares(
Expand All @@ -210,6 +200,16 @@ public function transfer(
$move
);
}

$destinationPath = $finalTarget . '/' . $path;
// restore the shares
$this->restoreShares(
$sourceUid,
$destinationUid,
$destinationPath,
$shares,
$output
);
}

private function walkFiles(View $view, $path, Closure $callBack) {
Expand Down Expand Up @@ -488,9 +488,6 @@ private function restoreShares(
}
} catch (\OCP\Files\NotFoundException $e) {
$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
} catch (\OCP\Share\Exceptions\GenericShareException $e) {
$output->writeln('<error>Share with id ' . $share->getId() . ' is broken, deleting</error>');
$this->shareManager->deleteShare($share);
} catch (\Throwable $e) {
$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getMessage() . ' : ' . $e->getTraceAsString() . '</error>');
}
Expand Down