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

[stable28] fix: improve checks for moving shares/storages into other mounts #50160

Draft
wants to merge 6 commits into
base: stable28
Choose a base branch
from

Conversation

backportbot[bot]
Copy link

@backportbot backportbot bot commented Jan 13, 2025

Backport of #49552

Warning, This backport's changes differ from the original and might be incomplete ⚠️

Todo

  • Review and resolve any conflicts
  • Remove all the empty commits
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@hamza221
Copy link
Contributor

/compile /

Signed-off-by: nextcloud-command <[email protected]>
@@ -95,6 +96,7 @@
private bool $updaterEnabled = true;
private UserManager $userManager;
private LoggerInterface $logger;
private IL10N $l10n;

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OC\Files\IL10N does not exist
@@ -109,6 +111,7 @@
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
$this->userManager = \OC::$server->getUserManager();
$this->logger = \OC::$server->get(LoggerInterface::class);
$this->l10n = \OC::$server->get(IFactory::class)->get('files');

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OC\Files\IFactory does not exist
@@ -788,6 +794,12 @@
try {
$this->changeLock($target, ILockingProvider::LOCK_EXCLUSIVE, true);

if ($checkSubMounts) {
$movedMounts = $mountManager->findIn($this->getAbsolutePath($source));

Check failure

Code scanning / Psalm

UndefinedVariable Error

Cannot find referenced variable $mountManager
@@ -806,13 +818,19 @@
}
// moving a file/folder within the same mount point
} elseif ($storage1 === $storage2) {
if (count($movedMounts) > 0) {
$this->validateMountMove($movedMounts, $mount1, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2));

Check failure

Code scanning / Psalm

UndefinedVariable Error

Cannot find referenced variable $targetUser
if ($storage1) {
$result = $storage1->rename($internalPath1, $internalPath2);
} else {
$result = false;
}
// moving a file/folder between storages (from $storage1 to $storage2)
} else {
if (count($movedMounts) > 0) {
$this->validateMountMove($movedMounts, $mount1, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2));

Check failure

Code scanning / Psalm

UndefinedVariable Error

Cannot find referenced variable $targetUser
if ($sourceMount instanceof SharedMount) {
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false);
} else {
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false);

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OC\Files\IL10N does not exist
if ($sourceMount !== $targetMount) {
if ($sourceMount instanceof SharedMount) {
if ($targetMount instanceof SharedMount) {
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OC\Files\IL10N does not exist
if ($targetMount instanceof SharedMount) {
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);
} else {
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OC\Files\IL10N does not exist
}
} else {
if ($targetMount instanceof SharedMount) {
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OC\Files\IL10N does not exist
if ($targetMount instanceof SharedMount) {
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);
} else {
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OC\Files\IL10N does not exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants