Skip to content

Commit

Permalink
Return false in hasUpdated when storage is not available
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
PVince81 committed Nov 5, 2021
1 parent 51317a8 commit db29fd2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/private/Files/Storage/Wrapper/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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(
Expand All @@ -459,7 +463,9 @@ protected function setUnavailable(StorageNotAvailableException $e) {
);
}
$this->getStorageCache()->setAvailability(false, $delay);
throw $e;
if ($e !== null) {
throw $e;
}
}


Expand Down

0 comments on commit db29fd2

Please sign in to comment.