From b8c61b3515ef406c4feafc851f12262e417ba157 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 1 Jun 2023 20:19:24 +0200 Subject: fix(caching): Avoid checking existence before fetching The cache might expire between checking for key existence and fetching the value. In this rare case the code continues with a null value when it doesn't expect one. Signed-off-by: Christoph Wurst --- apps/files_external/lib/Lib/Storage/Swift.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apps/files_external/lib/Lib/Storage/Swift.php') diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index 85b3727f4db..26e6c5315cb 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -126,9 +126,10 @@ class Swift extends \OC\Files\Storage\Common { * @throws \OCP\Files\StorageNotAvailableException */ private function fetchObject(string $path) { - if ($this->objectCache->hasKey($path)) { + $cached = $this->objectCache->get($path); + if ($cached !== null) { // might be "false" if object did not exist from last check - return $this->objectCache->get($path); + return $cached; } try { $object = $this->getContainer()->getObject($path); -- cgit v1.2.3