Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always allow moving mountpoints inside the same mountpoint #14691

Merged
merged 1 commit into from Mar 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/private/Files/View.php
Expand Up @@ -59,6 +59,7 @@
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\ReservedWordException;
use OCP\Files\Storage\IStorage;
use OCP\ILogger;
use OCP\IUser;
use OCP\Lock\ILockingProvider;
Expand Down Expand Up @@ -786,7 +787,8 @@ public function rename($path1, $path2) {

if ($internalPath1 === '') {
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
*/
Expand Down Expand Up @@ -1753,18 +1755,11 @@ private function assertPathLength($path) {
* It is not allowed to move a mount point into a different mount point or
* into an already shared folder
*
* @param string $target path
* @param IStorage $targetStorage
* @param string $targetInternalPath
* @return boolean
*/
private function isTargetAllowed($target) {

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;
}
private function targetIsNotShared(IStorage $targetStorage, string $targetInternalPath) {

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