From 0ae7653afbcf0004dec36ab2930ddf7ba0da450e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 19 Aug 2022 14:52:29 +0200 Subject: [PATCH] also hard error if the home storage can't be created Signed-off-by: Robin Appelman --- lib/private/Files/Mount/MountPoint.php | 4 +++- tests/lib/Files/Mount/MountPointTest.php | 2 +- tests/lib/TestCase.php | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 49f7e560ad3..bb225b5230f 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -171,7 +171,9 @@ class MountPoint implements IMountPoint { $this->invalidStorage = true; if ($this->mountPoint === '/') { // the root storage could not be initialized, show the user! - throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception); + throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', (int)$exception->getCode(), $exception); + } elseif (substr_count($this->mountPoint, '/') == 2) { // home mount is `/getCode(), $exception); } else { \OC::$server->get(LoggerInterface::class)->error($exception->getMessage(), ['exception' => $exception]); } diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php index 106a8f9a932..0776d13939b 100644 --- a/tests/lib/Files/Mount/MountPointTest.php +++ b/tests/lib/Files/Mount/MountPointTest.php @@ -56,7 +56,7 @@ class MountPointTest extends \Test\TestCase { $mountPoint = new \OC\Files\Mount\MountPoint( // just use this because a real class is needed '\Test\Files\Mount\DummyStorage', - '/mountpoint', + '/mountpoint/test', null, $loader ); diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 5bc64c2f0da..7353caad4ca 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -33,6 +33,7 @@ use OC\Files\Mount\RootMountProvider; use OC\Files\SetupManager; use OC\Template\Base; use OC\User\DisplayNameCache; +use OC\User\Manager; use OCP\Command\IBus; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Defaults; @@ -149,6 +150,10 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { call_user_func([$this, $methodName]); } } + + /** @var Manager $userManager */ + $userManager = \OC::$server->get(Manager::class); + $userManager->getDisplayNameCache()->clear(); } protected function onNotSuccessfulTest(\Throwable $t): void { @@ -202,7 +207,9 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { } } - \OC::$server->get(DisplayNameCache::class)->clear(); + /** @var Manager $userManager */ + $userManager = \OC::$server->get(Manager::class); + $userManager->getDisplayNameCache()->clear(); } /**