Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] fix: better error when trying to move a shared mount into a different storage #48555

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
$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 @@
$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
Loading