From db29fd29eed9d5307cbd6df4603dd1747a6d8a46 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 21 Oct 2021 22:53:33 +0200 Subject: [PATCH] Return false in hasUpdated when storage is not available Technically, saying that a storage has no updates when it's not available is correct. This makes it possible to retrieve the cache entry for the mount point and also to list and remove unavailable federated shares. Signed-off-by: Vincent Petry --- lib/private/Files/Storage/Wrapper/Availability.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php index b6d1ba2178ba0..1b532e3ba04cc 100644 --- a/lib/private/Files/Storage/Wrapper/Availability.php +++ b/lib/private/Files/Storage/Wrapper/Availability.php @@ -379,11 +379,15 @@ public function getLocalFile($path) { /** {@inheritdoc} */ public function hasUpdated($path, $time) { - $this->checkAvailability(); + if (!$this->isAvailable()) { + return false; + } try { return parent::hasUpdated($path, $time); } catch (StorageNotAvailableException $e) { - $this->setUnavailable($e); + // set unavailable but don't rethrow + $this->setUnavailable(null); + return false; } } @@ -449,7 +453,7 @@ public function getMetaData($path) { /** * @throws StorageNotAvailableException */ - protected function setUnavailable(StorageNotAvailableException $e) { + protected function setUnavailable(?StorageNotAvailableException $e) { $delay = self::RECHECK_TTL_SEC; if ($e instanceof StorageAuthException) { $delay = max( @@ -459,7 +463,9 @@ protected function setUnavailable(StorageNotAvailableException $e) { ); } $this->getStorageCache()->setAvailability(false, $delay); - throw $e; + if ($e !== null) { + throw $e; + } }