diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-02 18:27:43 +0300 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-11-07 22:34:49 +0300 |
commit | 03f40e1d4645918bd2d30cfe579acf42a9328c73 (patch) | |
tree | b2a8b59b0cea651efb2c9e9bd4cecc53a42ab64a /apps | |
parent | 6accf54d906afb55eb69c0a04ec165d3c0cff037 (diff) |
Skip broken shares when transferring ownership
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/command/transferownership.php | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/apps/files/command/transferownership.php b/apps/files/command/transferownership.php index 1f46efdde0d..606b9360939 100644 --- a/apps/files/command/transferownership.php +++ b/apps/files/command/transferownership.php @@ -215,22 +215,28 @@ class TransferOwnership extends Command { $progress = new ProgressBar($output, count($this->shares)); foreach($this->shares as $share) { - if ($share->getSharedWith() === $this->destinationUser) { - // Unmount the shares before deleting, so we don't try to get the storage later on. - $shareMountPoint = $this->mountManager->find('/' . $this->destinationUser . '/files' . $share->getTarget()); - if ($shareMountPoint) { - $this->mountManager->removeMount($shareMountPoint->getMountPoint()); - } - $this->shareManager->deleteShare($share); - } else { - if ($share->getShareOwner() === $this->sourceUser) { - $share->setShareOwner($this->destinationUser); - } - if ($share->getSharedBy() === $this->sourceUser) { - $share->setSharedBy($this->destinationUser); - } + try { + if ($share->getSharedWith() === $this->destinationUser) { + // Unmount the shares before deleting, so we don't try to get the storage later on. + $shareMountPoint = $this->mountManager->find('/' . $this->destinationUser . '/files' . $share->getTarget()); + if ($shareMountPoint) { + $this->mountManager->removeMount($shareMountPoint->getMountPoint()); + } + $this->shareManager->deleteShare($share); + } else { + if ($share->getShareOwner() === $this->sourceUser) { + $share->setShareOwner($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(); } |