Skip to content

Commit

Permalink
fix: better error when trying to move a shared mount into a different…
Browse files Browse the repository at this point in the history
… storage

Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Oct 3, 2024
1 parent 004d7da commit 19aeffa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand Down Expand Up @@ -751,16 +752,18 @@ public function rename($source, $target) {
$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

Check failure on line 760 in lib/private/Files/View.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

lib/private/Files/View.php:760:73: UndefinedConstant: Const s is not defined (see https://psalm.dev/020)
try {

Check failure on line 761 in lib/private/Files/View.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

ParseError

lib/private/Files/View.php:761:6: ParseError: Syntax error, unexpected T_TRY on line 761 (see https://psalm.dev/173)
$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
Expand All @@ -769,7 +772,7 @@ public function rename($source, $target) {
$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;
Expand Down

0 comments on commit 19aeffa

Please sign in to comment.