From b79b08da4275d422e5d9d93211d824d5634acec2 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Thu, 19 Aug 2021 12:28:10 +0200 Subject: [PATCH] Fix folder size contained in S3 buckets If 'filesystem_check_changes' was set to never, the cached size was alway set to -1 (Pending) on every access Signed-off-by: Louis Chemineau --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 9ea278d7229e5..1e8be4131fe34 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -380,13 +380,14 @@ public function stat($path) { try { $stat = []; if ($this->is_dir($path)) { - //folders don't really exist - $stat['size'] = -1; //unknown - $stat['mtime'] = time(); $cacheEntry = $this->getCache()->get($path); - if ($cacheEntry instanceof CacheEntry && $this->getMountOption('filesystem_check_changes', 1) !== 1) { + if ($cacheEntry instanceof CacheEntry) { $stat['size'] = $cacheEntry->getSize(); $stat['mtime'] = $cacheEntry->getMTime(); + } else { + // Use dummy values + $stat['size'] = -1; // Pending + $stat['mtime'] = time(); } } else { $stat['size'] = $this->getContentLength($path); @@ -401,6 +402,10 @@ public function stat($path) { } } + public function hasUpdated($path, $time) { + return $this->getMountOption('filesystem_check_changes', 1) === 1 || parent::hasUpdated($path, $time); + } + /** * Return content length for object *