Merge pull request #14691 from nextcloud/rename-mountpoint-within-mountpoint

always allow moving mountpoints inside the same mountpoint
This commit is contained in:
Roeland Jago Douma 2019-03-20 10:58:10 +01:00 committed by GitHub
commit 6458dd841c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 11 deletions

View File

@ -59,6 +59,7 @@ use OCP\Files\InvalidPathException;
use OCP\Files\Mount\IMountPoint; use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\Files\ReservedWordException; use OCP\Files\ReservedWordException;
use OCP\Files\Storage\IStorage;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUser; use OCP\IUser;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;
@ -786,7 +787,8 @@ class View {
if ($internalPath1 === '') { if ($internalPath1 === '') {
if ($mount1 instanceof MoveableMount) { if ($mount1 instanceof MoveableMount) {
if ($this->isTargetAllowed($absolutePath2)) { $sourceParentMount = $this->getMount(dirname($path1));
if ($sourceParentMount === $mount2 && $this->targetIsNotShared($storage2, $internalPath2)) {
/** /**
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1 * @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
*/ */
@ -1753,18 +1755,11 @@ class View {
* It is not allowed to move a mount point into a different mount point or * It is not allowed to move a mount point into a different mount point or
* into an already shared folder * into an already shared folder
* *
* @param string $target path * @param IStorage $targetStorage
* @param string $targetInternalPath
* @return boolean * @return boolean
*/ */
private function isTargetAllowed($target) { private function targetIsNotShared(IStorage $targetStorage, string $targetInternalPath) {
list($targetStorage, $targetInternalPath) = \OC\Files\Filesystem::resolvePath($target);
if (!$targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
\OCP\Util::writeLog('files',
'It is not allowed to move one mount point into another one',
ILogger::DEBUG);
return false;
}
// note: cannot use the view because the target is already locked // note: cannot use the view because the target is already locked
$fileId = (int)$targetStorage->getCache()->getId($targetInternalPath); $fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);