summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-11-07 20:20:16 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-14 15:18:34 +0100
commit2b61b89391dfdacf0c1aa979e37224ebe4f2d4d1 (patch)
tree778a3651fb602f1a8634210678e3468640e563be /apps
parentcebb68992509215163f6776b76e48411a31a287e (diff)
downloadnextcloud-server-2b61b89391dfdacf0c1aa979e37224ebe4f2d4d1.tar.gz
nextcloud-server-2b61b89391dfdacf0c1aa979e37224ebe4f2d4d1.zip
Skip broken shares when transferring ownership (#26527)
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Command/TransferOwnership.php36
1 files changed, 21 insertions, 15 deletions
diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php
index 3b51e4a9e6d..7ae968932d9 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();
}