Skip to content

Commit 0522b03

Browse files
committed
fix(files): Don't do session related work in the constructor of the View
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent a4760ef commit 0522b03

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/private/Files/View.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use OCP\Files\Mount\IMountPoint;
2929
use OCP\Files\NotFoundException;
3030
use OCP\Files\ReservedWordException;
31-
use OCP\IL10N;
3231
use OCP\IUser;
3332
use OCP\IUserManager;
3433
use OCP\L10N\IFactory;
@@ -62,7 +61,7 @@ class View {
6261
private bool $updaterEnabled = true;
6362
private UserManager $userManager;
6463
private LoggerInterface $logger;
65-
private IL10N $l10n;
64+
private IFactory $l10nFactory;
6665

6766
/**
6867
* @throws \Exception If $root contains an invalid path
@@ -77,7 +76,7 @@ public function __construct(string $root = '') {
7776
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
7877
$this->userManager = \OC::$server->getUserManager();
7978
$this->logger = \OC::$server->get(LoggerInterface::class);
80-
$this->l10n = \OC::$server->get(IFactory::class)->get('files');
79+
$this->l10nFactory = \OC::$server->get(IFactory::class);
8180
}
8281

8382
/**
@@ -867,6 +866,7 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou
867866
$targetPath = $targetMount->getMountPoint();
868867
}
869868

869+
$l = $this->l10nFactory->get('files');
870870
foreach ($mounts as $mount) {
871871
$sourcePath = $this->getRelativePath($mount->getMountPoint());
872872
if ($sourcePath) {
@@ -876,29 +876,29 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou
876876
}
877877

878878
if (!$mount instanceof MoveableMount) {
879-
throw new ForbiddenException($this->l10n->t('Storage %s cannot be moved', [$sourcePath]), false);
879+
throw new ForbiddenException($l->t('Storage %s cannot be moved', [$sourcePath]), false);
880880
}
881881

882882
if ($targetIsShared) {
883883
if ($sourceMount instanceof SharedMount) {
884-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false);
884+
throw new ForbiddenException($l->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false);
885885
} else {
886-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false);
886+
throw new ForbiddenException($l->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false);
887887
}
888888
}
889889

890890
if ($sourceMount !== $targetMount) {
891891
if ($sourceMount instanceof SharedMount) {
892892
if ($targetMount instanceof SharedMount) {
893-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);
893+
throw new ForbiddenException($l->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);
894894
} else {
895-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
895+
throw new ForbiddenException($l->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
896896
}
897897
} else {
898898
if ($targetMount instanceof SharedMount) {
899-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);
899+
throw new ForbiddenException($l->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);
900900
} else {
901-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
901+
throw new ForbiddenException($l->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
902902
}
903903
}
904904
}

0 commit comments

Comments
 (0)