From 5951748b338a39ae8754bdecb70a541c0a8e4185 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 18 Nov 2026 19:11:21 -0100 Subject: [PATCH] fix(files): don't apply the availability recheck delay twice Signed-off-by: Maxence Lange --- lib/private/Files/Cache/Storage.php | 7 ++++--- lib/private/Files/Storage/Wrapper/Availability.php | 10 +++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php index 7f8869d69bbb1..888dd6ed9a165 100644 --- a/lib/private/Files/Cache/Storage.php +++ b/lib/private/Files/Cache/Storage.php @@ -11,6 +11,7 @@ namespace OC\Files\Cache; use OC\DB\Exceptions\DbalException; +use OC\Files\Storage\Wrapper\Availability; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Storage\IStorage; use OCP\FilesMetadata\IFilesMetadataManager; @@ -142,9 +143,9 @@ public function getAvailability(): array { } /** - * @param int $delay amount of seconds to delay reconsidering that storage further + * @param int $additionalDelay additional delay - {@see Availability::shouldRecheck()} already waits {@see Availability::RECHECK_TTL_SEC} */ - public function setAvailability(bool $isAvailable, int $delay = 0): void { + public function setAvailability(bool $isAvailable, int $additionalDelay = 0): void { $available = $isAvailable ? 1 : 0; if (!$isAvailable) { Server::get(LoggerInterface::class)->info('Storage with ' . $this->storageId . ' marked as unavailable', ['app' => 'lib']); @@ -153,7 +154,7 @@ public function setAvailability(bool $isAvailable, int $delay = 0): void { $query = Server::get(IDBConnection::class)->getQueryBuilder(); $query->update('storages') ->set('available', $query->createNamedParameter($available)) - ->set('last_checked', $query->createNamedParameter(time() + $delay)) + ->set('last_checked', $query->createNamedParameter(time() + $additionalDelay)) ->where($query->expr()->eq('id', $query->createNamedParameter($this->storageId))); $query->executeStatement(); } diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php index 0f040fe703b07..8caace6807bcb 100644 --- a/lib/private/Files/Storage/Wrapper/Availability.php +++ b/lib/private/Files/Storage/Wrapper/Availability.php @@ -294,16 +294,12 @@ public function getMetaData(string $path): ?array { * @throws StorageNotAvailableException */ protected function setUnavailable(?StorageNotAvailableException $e): void { - $delay = self::RECHECK_TTL_SEC; + $additionalDelay = 0; if ($e instanceof StorageAuthException) { - $delay = max( - // 30min - $this->config->getSystemValueInt('external_storage.auth_availability_delay', 1800), - self::RECHECK_TTL_SEC - ); + $additionalDelay = max($this->config->getSystemValueInt('external_storage.auth_availability_delay', 1800) - self::RECHECK_TTL_SEC, 0); } $this->available = false; - $this->getStorageCache()->setAvailability(false, $delay); + $this->getStorageCache()->setAvailability(false, $additionalDelay); if ($e !== null) { throw $e; }