diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2016-11-14 17:07:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-14 17:07:59 +0100 |
commit | 561a4fd9892b7d365f871e79fcf910da200ba69e (patch) | |
tree | 28f832f2e53a1790e3e63acbfa9e856bb740391e /apps/files | |
parent | b7e13b43fbcaf874b52eadb881e6265340b7cde8 (diff) | |
parent | 2b61b89391dfdacf0c1aa979e37224ebe4f2d4d1 (diff) | |
download | nextcloud-server-561a4fd9892b7d365f871e79fcf910da200ba69e.tar.gz nextcloud-server-561a4fd9892b7d365f871e79fcf910da200ba69e.zip |
Merge pull request #2115 from nextcloud/oc_26527
Skip broken shares when transferring ownership (#26527)
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Command/TransferOwnership.php | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php index c8366be32c4..cd776aaa4ef 100644 --- a/apps/files/lib/Command/TransferOwnership.php +++ b/apps/files/lib/Command/TransferOwnership.php @@ -224,22 +224,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(); } |