aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2025-01-03 17:41:39 +0100
committerRobin Appelman <robin@icewind.nl>2025-02-05 15:07:25 +0100
commit0549f57f88dcd71f28612a11bcb9ccdc161c89d4 (patch)
treec4f8275ca3ffc08c8ff8c24d97dc9c2de521c96e
parent421ea504344facab5068f5213ddea33fd8b17c64 (diff)
downloadnextcloud-server-0549f57f88dcd71f28612a11bcb9ccdc161c89d4.tar.gz
nextcloud-server-0549f57f88dcd71f28612a11bcb9ccdc161c89d4.zip
fix: explicitly ignore nested mounts when transfering ownership
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php2
-rw-r--r--apps/files/lib/Service/OwnershipTransferService.php2
-rw-r--r--build/integration/features/transfer-ownership.feature2
-rw-r--r--lib/private/Files/View.php12
4 files changed, 12 insertions, 6 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index 0f41ff97cc6..2d4ba472d00 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -62,7 +62,7 @@ class TestViewDirectory extends \OC\Files\View {
return $this->deletables[$path];
}
- public function rename($path1, $path2) {
+ public function rename($path1, $path2, array $options = []) {
return $this->canRename;
}
diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php
index e28fbfe19bd..56699ca09f0 100644
--- a/apps/files/lib/Service/OwnershipTransferService.php
+++ b/apps/files/lib/Service/OwnershipTransferService.php
@@ -416,7 +416,7 @@ class OwnershipTransferService {
$view->mkdir($finalTarget);
$finalTarget = $finalTarget . '/' . basename($sourcePath);
}
- if ($view->rename($sourcePath, $finalTarget) === false) {
+ if ($view->rename($sourcePath, $finalTarget, ['checkSubMounts' => false]) === false) {
throw new TransferOwnershipException("Could not transfer files.", 1);
}
if (!is_dir("$sourceUid/files")) {
diff --git a/build/integration/features/transfer-ownership.feature b/build/integration/features/transfer-ownership.feature
index 22e34dcf7af..30a4ad52bb3 100644
--- a/build/integration/features/transfer-ownership.feature
+++ b/build/integration/features/transfer-ownership.feature
@@ -511,7 +511,7 @@ Feature: transfer-ownership
And user "user2" accepts last share
When transferring ownership of path "test" from "user0" to "user1"
Then the command failed with exit code 1
- And the command output contains the text "Could not transfer files."
+ And the command error output contains the text "Moving a storage (user0/files/test) into another storage (user1) is not allowed"
Scenario: transferring ownership does not transfer received shares
Given user "user0" exists
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index c8b17f330c4..928058c9f83 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -730,11 +730,14 @@ class View {
*
* @param string $source source path
* @param string $target target path
+ * @param array $options
*
* @return bool|mixed
* @throws LockedException
*/
- public function rename($source, $target) {
+ public function rename($source, $target, array $options = []) {
+ $checkSubMounts = $options['checkSubMounts'] ?? true;
+
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
@@ -798,13 +801,16 @@ class View {
try {
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true);
- $movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
+ if ($checkSubMounts) {
+ $movedMounts = $mountManager->findIn($this->getAbsolutePath($source));
+ } else {
+ $movedMounts = [];
+ }
if ($internalPath1 === '') {
$sourceParentMount = $this->getMount(dirname($source));
$movedMounts[] = $mount1;
$this->validateMountMove($movedMounts, $sourceParentMount, $mount2, !$this->targetIsNotShared($storage2, $internalPath2));
-
/**
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
*/