Skip to content

Commit 5066a67

Browse files
authored
Merge pull request #14760 from nextcloud/backport/14691/stable14
[stable14] always allow moving mountpoints inside the same mountpoint
2 parents 863e17d + d47106c commit 5066a67

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

lib/private/Files/View.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
use OCP\Files\Mount\IMountPoint;
6060
use OCP\Files\NotFoundException;
6161
use OCP\Files\ReservedWordException;
62+
use OCP\Files\Storage\IStorage;
6263
use OCP\ILogger;
6364
use OCP\IUser;
6465
use OCP\Lock\ILockingProvider;
@@ -786,7 +787,8 @@ public function rename($path1, $path2) {
786787

787788
if ($internalPath1 === '') {
788789
if ($mount1 instanceof MoveableMount) {
789-
if ($this->isTargetAllowed($absolutePath2)) {
790+
$sourceParentMount = $this->getMount(dirname($path1));
791+
if ($sourceParentMount === $mount2 && $this->targetIsNotShared($storage2, $internalPath2)) {
790792
/**
791793
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
792794
*/
@@ -1750,18 +1752,11 @@ private function assertPathLength($path) {
17501752
* It is not allowed to move a mount point into a different mount point or
17511753
* into an already shared folder
17521754
*
1753-
* @param string $target path
1755+
* @param IStorage $targetStorage
1756+
* @param string $targetInternalPath
17541757
* @return boolean
17551758
*/
1756-
private function isTargetAllowed($target) {
1757-
1758-
list($targetStorage, $targetInternalPath) = \OC\Files\Filesystem::resolvePath($target);
1759-
if (!$targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
1760-
\OCP\Util::writeLog('files',
1761-
'It is not allowed to move one mount point into another one',
1762-
ILogger::DEBUG);
1763-
return false;
1764-
}
1759+
private function targetIsNotShared(IStorage $targetStorage, string $targetInternalPath) {
17651760

17661761
// note: cannot use the view because the target is already locked
17671762
$fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);

0 commit comments

Comments
 (0)