Merge pull request #2115 from nextcloud/oc_26527
Skip broken shares when transferring ownership (#26527)
This commit is contained in:
commit
561a4fd989
|
@ -224,22 +224,28 @@ class TransferOwnership extends Command {
|
||||||
$progress = new ProgressBar($output, count($this->shares));
|
$progress = new ProgressBar($output, count($this->shares));
|
||||||
|
|
||||||
foreach($this->shares as $share) {
|
foreach($this->shares as $share) {
|
||||||
if ($share->getSharedWith() === $this->destinationUser) {
|
try {
|
||||||
// Unmount the shares before deleting, so we don't try to get the storage later on.
|
if ($share->getSharedWith() === $this->destinationUser) {
|
||||||
$shareMountPoint = $this->mountManager->find('/' . $this->destinationUser . '/files' . $share->getTarget());
|
// Unmount the shares before deleting, so we don't try to get the storage later on.
|
||||||
if ($shareMountPoint) {
|
$shareMountPoint = $this->mountManager->find('/' . $this->destinationUser . '/files' . $share->getTarget());
|
||||||
$this->mountManager->removeMount($shareMountPoint->getMountPoint());
|
if ($shareMountPoint) {
|
||||||
}
|
$this->mountManager->removeMount($shareMountPoint->getMountPoint());
|
||||||
$this->shareManager->deleteShare($share);
|
}
|
||||||
} else {
|
$this->shareManager->deleteShare($share);
|
||||||
if ($share->getShareOwner() === $this->sourceUser) {
|
} else {
|
||||||
$share->setShareOwner($this->destinationUser);
|
if ($share->getShareOwner() === $this->sourceUser) {
|
||||||
}
|
$share->setShareOwner($this->destinationUser);
|
||||||
if ($share->getSharedBy() === $this->sourceUser) {
|
}
|
||||||
$share->setSharedBy($this->destinationUser);
|
if ($share->getSharedBy() === $this->sourceUser) {
|
||||||
}
|
$share->setSharedBy($this->destinationUser);
|
||||||
|
}
|
||||||
|
|
||||||
$this->shareManager->updateShare($share);
|
$this->shareManager->updateShare($share);
|
||||||
|
}
|
||||||
|
} catch (\OCP\Files\NotFoundException $e) {
|
||||||
|
$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getTraceAsString() . '</error>');
|
||||||
}
|
}
|
||||||
$progress->advance();
|
$progress->advance();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue