diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-11-21 12:34:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-21 12:34:17 +0300 |
commit | 85c8a026cad399c4c3d81e658c3b5518290be9eb (patch) | |
tree | 5bb0abc9e699d46ede6dfa576e9dd7a3f2e20950 /apps | |
parent | 0360d6f9ba20eb7de39ccdd4d9e809e0bd5aa564 (diff) | |
parent | 03f40e1d4645918bd2d30cfe579acf42a9328c73 (diff) |
Merge pull request #26576 from owncloud/stable9-transfer-ownership-exceptions
[stable9] 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 89e3963c8cb..bf708c407a7 100644 --- a/apps/files/command/transferownership.php +++ b/apps/files/command/transferownership.php @@ -220,22 +220,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(); } |