Merge pull request #23764 from owncloud/backport-23743-transfer-ownership

[9.0] Unmount the share before deleting it, so we don't try to use it later on
This commit is contained in:
Thomas Müller 2016-04-04 16:48:29 +02:00
commit 277c9f4a03
2 changed files with 13 additions and 3 deletions

View File

@ -24,8 +24,9 @@
$dbConnection = \OC::$server->getDatabaseConnection();
$userManager = OC::$server->getUserManager();
$shareManager = \OC::$server->getShareManager();
$mountManager = \OC::$server->getMountManager();
/** @var Symfony\Component\Console\Application $application */
$application->add(new OCA\Files\Command\Scan($userManager));
$application->add(new OCA\Files\Command\DeleteOrphanedFiles($dbConnection));
$application->add(new OCA\Files\Command\TransferOwnership($userManager, $shareManager));
$application->add(new OCA\Files\Command\TransferOwnership($userManager, $shareManager, $mountManager));

View File

@ -24,7 +24,7 @@ namespace OCA\Files\Command;
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\Mount\IMountManager;
use OCP\IUserManager;
use OCP\Share\IManager;
use OCP\Share\IShare;
@ -42,6 +42,9 @@ class TransferOwnership extends Command {
/** @var IManager */
private $shareManager;
/** @var IMountManager */
private $mountManager;
/** @var FileInfo[] */
private $allFiles = [];
@ -60,9 +63,10 @@ class TransferOwnership extends Command {
/** @var string */
private $finalTarget;
public function __construct(IUserManager $userManager, IManager $shareManager) {
public function __construct(IUserManager $userManager, IManager $shareManager, IMountManager $mountManager) {
$this->userManager = $userManager;
$this->shareManager = $shareManager;
$this->mountManager = $mountManager;
parent::__construct();
}
@ -206,6 +210,11 @@ class TransferOwnership extends Command {
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) {