Skip to content

Commit 56e6eff

Browse files
committed
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 <come.chilliet@nextcloud.com>
1 parent 14de2ce commit 56e6eff

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,6 @@ public function transfer(
147147
$output
148148
);
149149

150-
$destinationPath = $finalTarget . '/' . $path;
151-
// restore the shares
152-
$this->restoreShares(
153-
$sourceUid,
154-
$destinationUid,
155-
$destinationPath,
156-
$shares,
157-
$output
158-
);
159-
160150
// transfer the incoming shares
161151
if ($transferIncomingShares === true) {
162152
$sourceShares = $this->collectIncomingShares(
@@ -181,6 +171,16 @@ public function transfer(
181171
$move
182172
);
183173
}
174+
175+
$destinationPath = $finalTarget . '/' . $path;
176+
// restore the shares
177+
$this->restoreShares(
178+
$sourceUid,
179+
$destinationUid,
180+
$destinationPath,
181+
$shares,
182+
$output
183+
);
184184
}
185185

186186
private function sanitizeFolderName(string $name): string {
@@ -442,9 +442,6 @@ private function restoreShares(
442442
}
443443
} catch (\OCP\Files\NotFoundException $e) {
444444
$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
445-
} catch (\OCP\Share\Exceptions\GenericShareException $e) {
446-
$output->writeln('<error>Share with id ' . $share->getId() . ' is broken, deleting</error>');
447-
$this->shareManager->deleteShare($share);
448445
} catch (\Throwable $e) {
449446
$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getMessage() . ' : ' . $e->getTraceAsString() . '</error>');
450447
}

0 commit comments

Comments
 (0)