aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-12-04 19:11:53 +0100
committerAndy Scherzinger <info@andy-scherzinger.de>2025-02-03 20:46:21 +0100
commit4a0cf40ceabbd06bce57f2b3b291315eb71cf270 (patch)
tree78b88c5e31522cfd096355a819122945bf60ea6f
parent9d2628d87133337528749ab9977c8832f366a4db (diff)
downloadnextcloud-server-backport/49552/stable31.tar.gz
nextcloud-server-backport/49552/stable31.zip
fix: translate mount move error messagesbackport/49552/stable31
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/View.php43
1 files changed, 32 insertions, 11 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 548b2a38d1e..c143f61dc6e 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -856,30 +856,51 @@ class View {
return $result;
}
+ /**
+ * @throws ForbiddenException
+ */
private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMountPoint $targetMount, bool $targetIsShared): void {
- $targetType = 'storage';
- if ($targetMount instanceof SharedMount) {
- $targetType = 'share';
+ $targetPath = $this->getRelativePath($targetMount->getMountPoint());
+ if ($targetPath) {
+ $targetPath = trim($targetPath, '/');
+ } else {
+ $targetPath = $targetMount->getMountPoint();
}
- $targetPath = rtrim($targetMount->getMountPoint(), '/');
foreach ($mounts as $mount) {
- $sourcePath = rtrim($mount->getMountPoint(), '/');
- $sourceType = 'storage';
- if ($mount instanceof SharedMount) {
- $sourceType = 'share';
+ $sourcePath = $this->getRelativePath($mount->getMountPoint());
+ if ($sourcePath) {
+ $sourcePath = trim($sourcePath, '/');
+ } else {
+ $sourcePath = $mount->getMountPoint();
}
if (!$mount instanceof MoveableMount) {
- throw new ForbiddenException("Storage {$sourcePath} cannot be moved", false);
+ throw new ForbiddenException($this->l10n->t('Storage %s cannot be moved', [$sourcePath]), false);
}
if ($targetIsShared) {
- throw new ForbiddenException("Moving a $sourceType ($sourcePath) into shared folder is not allowed", false);
+ 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);
+ }
}
if ($sourceMount !== $targetMount) {
- throw new ForbiddenException("Moving a $sourceType ($sourcePath) into another $targetType ($targetPath) is not allowed", false);
+ 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);
+ } else {
+ throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
+ }
+ } 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);
+ } else {
+ throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
+ }
+ }
}
}
}