Skip to content

Commit 757076a

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

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
@@ -42,7 +42,7 @@ public function isDeletable($path) {
4242
return $this->deletables[$path];
4343
}
4444

45-
public function rename($path1, $path2) {
45+
public function rename($path1, $path2, array $options = []) {
4646
return $this->canRename;
4747
}
4848

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ protected function transferFiles(string $sourceUid,
397397
$view->mkdir($finalTarget);
398398
$finalTarget = $finalTarget . '/' . basename($sourcePath);
399399
}
400-
if ($view->rename($sourcePath, $finalTarget) === false) {
400+
if ($view->rename($sourcePath, $finalTarget, ['checkSubMounts' => false]) === false) {
401401
throw new TransferOwnershipException('Could not transfer files.', 1);
402402
}
403403
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
@@ -514,7 +514,7 @@ Feature: transfer-ownership
514514
And user "user2" accepts last share
515515
When transferring ownership of path "test" from "user0" to "user1"
516516
Then the command failed with exit code 1
517-
And the command output contains the text "Could not transfer files."
517+
And the command error output contains the text "Moving a storage (user0/files/test) into another storage (user1) is not allowed"
518518

519519
Scenario: transferring ownership does not transfer received shares
520520
Given user "user0" exists

lib/private/Files/View.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,14 @@ public function deleteAll($directory) {
700700
*
701701
* @param string $source source path
702702
* @param string $target target path
703+
* @param array $options
703704
*
704705
* @return bool|mixed
705706
* @throws LockedException
706707
*/
707-
public function rename($source, $target) {
708+
public function rename($source, $target, array $options = []) {
709+
$checkSubMounts = $options['checkSubMounts'] ?? true;
710+
708711
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
709712
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
710713

@@ -772,13 +775,16 @@ public function rename($source, $target) {
772775
try {
773776
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true);
774777

775-
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
778+
if ($checkSubMounts) {
779+
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
780+
} else {
781+
$movedMounts = [];
782+
}
776783

777784
if ($internalPath1 === '') {
778785
$sourceParentMount = $this->getMount(dirname($source));
779786
$movedMounts[] = $mount1;
780787
$this->validateMountMove($movedMounts, $sourceParentMount, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2));
781-
782788
/**
783789
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
784790
*/

0 commit comments

Comments
 (0)