|
59 | 59 | use OCP\Files\Mount\IMountPoint; |
60 | 60 | use OCP\Files\NotFoundException; |
61 | 61 | use OCP\Files\ReservedWordException; |
| 62 | +use OCP\Files\Storage\IStorage; |
62 | 63 | use OCP\ILogger; |
63 | 64 | use OCP\IUser; |
64 | 65 | use OCP\Lock\ILockingProvider; |
@@ -786,7 +787,8 @@ public function rename($path1, $path2) { |
786 | 787 |
|
787 | 788 | if ($internalPath1 === '') { |
788 | 789 | if ($mount1 instanceof MoveableMount) { |
789 | | - if ($this->isTargetAllowed($absolutePath2)) { |
| 790 | + $sourceParentMount = $this->getMount(dirname($path1)); |
| 791 | + if ($sourceParentMount === $mount2 && $this->targetIsNotShared($storage2, $internalPath2)) { |
790 | 792 | /** |
791 | 793 | * @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1 |
792 | 794 | */ |
@@ -1750,18 +1752,11 @@ private function assertPathLength($path) { |
1750 | 1752 | * It is not allowed to move a mount point into a different mount point or |
1751 | 1753 | * into an already shared folder |
1752 | 1754 | * |
1753 | | - * @param string $target path |
| 1755 | + * @param IStorage $targetStorage |
| 1756 | + * @param string $targetInternalPath |
1754 | 1757 | * @return boolean |
1755 | 1758 | */ |
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) { |
1765 | 1760 |
|
1766 | 1761 | // note: cannot use the view because the target is already locked |
1767 | 1762 | $fileId = (int)$targetStorage->getCache()->getId($targetInternalPath); |
|
0 commit comments