aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-10-03 15:12:09 +0200
committerRobin Appelman <robin@icewind.nl>2024-10-03 15:12:09 +0200
commit19aeffa8b56e7bcc31c773e64c7519733f7426e2 (patch)
treefac3ee0a9a656e6d938b0884ca066243de2d07ab
parent004d7dac91b8e6759f0279e6f932fe03d6203ba2 (diff)
downloadnextcloud-server-share-move-storage-error.tar.gz
nextcloud-server-share-move-storage-error.zip
fix: better error when trying to move a shared mount into a different storageshare-move-storage-error
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/View.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 80679a9481f..f99bfdef64d 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -26,6 +26,7 @@ use OCP\Files\InvalidDirectoryException;
use OCP\Files\InvalidPathException;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
+use OCP\Files\NotPermittedException;
use OCP\Files\ReservedWordException;
use OCP\IUser;
use OCP\IUserManager;
@@ -751,16 +752,18 @@ class View {
$mount2 = $this->getMount($target);
$storage1 = $mount1->getStorage();
$storage2 = $mount2->getStorage();
+ $sourceParent = dirname($source);
+ $targetParent = dirname($target);
$internalPath1 = $mount1->getInternalPath($absolutePath1);
$internalPath2 = $mount2->getInternalPath($absolutePath2);
- $this->changeLock($source, ILockingProvider::LOCK_EXCLUSIVE, true);
+ $this->changeLock($source, ILockingProvider::LOCK_EXCLUSIVE, true);s
try {
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true);
if ($internalPath1 === '') {
if ($mount1 instanceof MoveableMount) {
- $sourceParentMount = $this->getMount(dirname($source));
+ $sourceParentMount = $this->getMount($sourceParent);
if ($sourceParentMount === $mount2 && $this->targetIsNotShared($targetUser, $absolutePath2)) {
/**
* @var \OC\Files\Mount\MountPoint | \OC\Files\Mount\MoveableMount $mount1
@@ -769,7 +772,7 @@ class View {
$result = $mount1->moveMount($absolutePath2);
$manager->moveMount($sourceMountPoint, $mount1->getMountPoint());
} else {
- $result = false;
+ throw new NotPermittedException("Not allowed to move $source to $target as $sourceParent is not the same storage as $targetParent");
}
} else {
$result = false;