Skip to content

Commit 2c71693

Browse files
committed
fix: explicitly ignore nested mounts when transfering ownership
Signed-off-by: Robin Appelman <[email protected]>
1 parent 1f2e168 commit 2c71693

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function isDeletable($path) {
6262
return $this->deletables[$path];
6363
}
6464

65-
public function rename($path1, $path2) {
65+
public function rename($path1, $path2, array $options = []) {
6666
return $this->canRename;
6767
}
6868

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ protected function transferFiles(string $sourceUid,
416416
$view->mkdir($finalTarget);
417417
$finalTarget = $finalTarget . '/' . basename($sourcePath);
418418
}
419-
if ($view->rename($sourcePath, $finalTarget) === false) {
419+
if ($view->rename($sourcePath, $finalTarget, ['checkSubMounts' => false]) === false) {
420420
throw new TransferOwnershipException("Could not transfer files.", 1);
421421
}
422422
if (!is_dir("$sourceUid/files")) {

build/integration/features/transfer-ownership.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ Feature: transfer-ownership
511511
And user "user2" accepts last share
512512
When transferring ownership of path "test" from "user0" to "user1"
513513
Then the command failed with exit code 1
514-
And the command output contains the text "Could not transfer files."
514+
And the command error output contains the text "Moving a storage (user0/files/test) into another storage (user1) is not allowed"
515515

516516
Scenario: transferring ownership does not transfer received shares
517517
Given user "user0" exists

lib/private/Files/View.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,14 @@ public function deleteAll($directory) {
730730
*
731731
* @param string $source source path
732732
* @param string $target target path
733+
* @param array $options
733734
*
734735
* @return bool|mixed
735736
* @throws LockedException
736737
*/
737-
public function rename($source, $target) {
738+
public function rename($source, $target, array $options = []) {
739+
$checkSubMounts = $options['checkSubMounts'] ?? true;
740+
738741
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
739742
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
740743

@@ -798,13 +801,16 @@ public function rename($source, $target) {
798801
try {
799802
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true);
800803

801-
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
804+
if ($checkSubMounts) {
805+
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
806+
} else {
807+
$movedMounts = [];
808+
}
802809

803810
if ($internalPath1 === '') {
804811
$sourceParentMount = $this->getMount(dirname($source));
805812
$movedMounts[] = $mount1;
806813
$this->validateMountMove($movedMounts, $sourceParentMount, $mount2, !$this->targetIsNotShared($storage2, $internalPath2));
807-
808814
/**
809815
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
810816
*/

0 commit comments

Comments
 (0)