]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix folder size contained in S3 buckets 28534/head
authorLouis Chemineau <louis@chmn.me>
Thu, 19 Aug 2021 10:28:10 +0000 (12:28 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 20 Aug 2021 13:35:22 +0000 (13:35 +0000)
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 <louis@chmn.me>
apps/files_external/lib/Lib/Storage/AmazonS3.php

index 32e74250a91d2e374870838c3b75d5332c76ca1a..220822f93961b49001aec408adbd01ae3e899f33 100644 (file)
@@ -384,13 +384,14 @@ class AmazonS3 extends \OC\Files\Storage\Common {
                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);
@@ -405,6 +406,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
                }
        }
 
+       public function hasUpdated($path, $time) {
+               return $this->getMountOption('filesystem_check_changes', 1) === 1 || parent::hasUpdated($path, $time);
+       }
+
        /**
         * Return content length for object
         *