From 8d1a3daa3fd7d1a4ecb7934662a76266a02ce225 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 3 Aug 2023 23:09:17 +0200 Subject: Allow ext storage Local to go unavailable Whenever an external storage of type Local points at a non-existing directory, process this as a StorageNotAvailable instead of returning 404. This makes desktop clients ignore the folder instead of deleting it when it becomes unavailable. The code change was limited to external storages to avoid issues during setup and with the default home storage. Signed-off-by: Vincent Petry --- tests/lib/Files/Storage/LocalTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php index e324d2b28db..1190a2b2da0 100644 --- a/tests/lib/Files/Storage/LocalTest.php +++ b/tests/lib/Files/Storage/LocalTest.php @@ -139,4 +139,15 @@ class LocalTest extends Storage { umask($oldMask); $this->assertTrue($this->instance->isUpdatable('test.txt')); } + + public function testUnavailableExternal() { + $this->expectException(\OCP\Files\StorageNotAvailableException::class); + $this->instance = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir . '/unexist', 'isExternal' => true]); + } + + public function testUnavailableNonExternal() { + $this->instance = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir . '/unexist']); + // no exception thrown + $this->assertNotNull($this->instance); + } } -- cgit v1.2.3