Skip to content

Commit 804a0ec

Browse files
icewind1991AndyScherzinger
authored andcommitted
fix: explicitly ignore nested mounts when transfering ownership
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 7a37fdd commit 804a0ec

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/files_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
@@ -732,11 +732,14 @@ public function deleteAll($directory) {
732732
*
733733
* @param string $source source path
734734
* @param string $target target path
735+
* @param array $options
735736
*
736737
* @return bool|mixed
737738
* @throws LockedException
738739
*/
739-
public function rename($source, $target) {
740+
public function rename($source, $target, array $options = []) {
741+
$checkSubMounts = $options['checkSubMounts'] ?? true;
742+
740743
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
741744
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
742745

@@ -800,13 +803,16 @@ public function rename($source, $target) {
800803
try {
801804
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true);
802805

803-
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
806+
if ($checkSubMounts) {
807+
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
808+
} else {
809+
$movedMounts = [];
810+
}
804811

805812
if ($internalPath1 === '') {
806813
$sourceParentMount = $this->getMount(dirname($source));
807814
$movedMounts[] = $mount1;
808815
$this->validateMountMove($movedMounts, $sourceParentMount, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2));
809-
810816
/**
811817
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
812818
*/

0 commit comments

Comments
 (0)