From 7e6dd024412437402bd03b2854111ff2185a481c Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 30 Nov 2017 21:29:06 +0100 Subject: [PATCH 1/2] A failed storage is a not available storage We have to double check. Since getting the info of the root returns a generic entry. But actually the stroage is not available. Else we get very weird sync and web behavior. Signed-off-by: Roeland Jago Douma --- apps/dav/lib/Connector/Sabre/ObjectTree.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/dav/lib/Connector/Sabre/ObjectTree.php b/apps/dav/lib/Connector/Sabre/ObjectTree.php index acc6dcc3be3cf..f37ffc19e290a 100644 --- a/apps/dav/lib/Connector/Sabre/ObjectTree.php +++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php @@ -29,6 +29,7 @@ namespace OCA\DAV\Connector\Sabre; +use OC\Files\Storage\FailedStorage; use OCA\DAV\Connector\Sabre\Exception\Forbidden; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCA\DAV\Connector\Sabre\Exception\FileLocked; @@ -158,6 +159,10 @@ public function getNodeForPath($path) { // read from cache try { $info = $this->fileView->getFileInfo($path); + + if ($info->getStorage()->instanceOfStorage(FailedStorage::class)) { + throw new StorageNotAvailableException(); + } } catch (StorageNotAvailableException $e) { throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage is temporarily not available'); } catch (StorageInvalidException $e) { From aedc59c6364a1fdddf59a6f47f500ce1857797ea Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 1 Dec 2017 12:34:37 +0100 Subject: [PATCH 2/2] Fix tests Signed-off-by: Roeland Jago Douma --- apps/dav/lib/Connector/Sabre/ObjectTree.php | 2 +- apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/Connector/Sabre/ObjectTree.php b/apps/dav/lib/Connector/Sabre/ObjectTree.php index f37ffc19e290a..bd2da1d25b29f 100644 --- a/apps/dav/lib/Connector/Sabre/ObjectTree.php +++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php @@ -160,7 +160,7 @@ public function getNodeForPath($path) { try { $info = $this->fileView->getFileInfo($path); - if ($info->getStorage()->instanceOfStorage(FailedStorage::class)) { + if ($info instanceof \OCP\Files\FileInfo && $info->getStorage()->instanceOfStorage(FailedStorage::class)) { throw new StorageNotAvailableException(); } } catch (StorageNotAvailableException $e) { diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index 53f60bd0f1c2d..efb6d88ae575b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -174,6 +174,8 @@ public function testGetNodeForPath( $fileInfo->expects($this->once()) ->method('getName') ->will($this->returnValue($outputFileName)); + $fileInfo->method('getStorage') + ->willReturn($this->createMock(\OC\Files\Storage\Common::class)); $view->expects($this->once()) ->method('getFileInfo')