From 3dac3a01c5008f1fcec37689e6e02845bd126db8 Mon Sep 17 00:00:00 2001
From: Joas Schilling <nickvergessen@owncloud.com>
Date: Fri, 1 Apr 2016 21:05:55 +0200
Subject: [PATCH] Unmount the share before deleting it, so we don't try to use
 it later on

---
 apps/files/command/transferownership.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/apps/files/command/transferownership.php b/apps/files/command/transferownership.php
index 3674727b167..98dbc428220 100644
--- a/apps/files/command/transferownership.php
+++ b/apps/files/command/transferownership.php
@@ -203,9 +203,15 @@ class TransferOwnership extends Command {
 	private function restoreShares(OutputInterface $output) {
 		$output->writeln("Restoring shares ...");
 		$progress = new ProgressBar($output, count($this->shares));
+		$mountManager = Filesystem::getMountManager($this->destinationUser);
 
 		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 = $mountManager->find('/' . $this->destinationUser . '/files' . $share->getTarget());
+				if ($shareMountPoint) {
+					$mountManager->removeMount($shareMountPoint->getMountPoint());
+				}
 				$this->shareManager->deleteShare($share);
 			} else {
 				if ($share->getShareOwner() === $this->sourceUser) {
-- 
GitLab