Merge pull request #21728 from nextcloud/bugfix/noid/s3-external-mtime-cache

Reuse cache for directory mtime/size if filesystem changes can be ignored
This commit is contained in:
Morris Jobke 2020-07-15 18:26:48 +02:00 committed by GitHub
commit 638e9438a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -45,6 +45,7 @@ use Aws\S3\S3Client;
use Icewind\Streams\CallbackWrapper; use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\IteratorDirectory; use Icewind\Streams\IteratorDirectory;
use OC\Cache\CappedMemoryCache; use OC\Cache\CappedMemoryCache;
use OC\Files\Cache\CacheEntry;
use OC\Files\ObjectStore\S3ConnectionTrait; use OC\Files\ObjectStore\S3ConnectionTrait;
use OC\Files\ObjectStore\S3ObjectTrait; use OC\Files\ObjectStore\S3ObjectTrait;
use OCP\Constants; use OCP\Constants;
@ -374,6 +375,11 @@ class AmazonS3 extends \OC\Files\Storage\Common {
//folders don't really exist //folders don't really exist
$stat['size'] = -1; //unknown $stat['size'] = -1; //unknown
$stat['mtime'] = time(); $stat['mtime'] = time();
$cacheEntry = $this->getCache()->get($path);
if ($cacheEntry instanceof CacheEntry && $this->getMountOption('filesystem_check_changes', 1) !== 1) {
$stat['size'] = $cacheEntry->getSize();
$stat['mtime'] = $cacheEntry->getMTime();
}
} else { } else {
$stat['size'] = $this->getContentLength($path); $stat['size'] = $this->getContentLength($path);
$stat['mtime'] = strtotime($this->getLastModified($path)); $stat['mtime'] = strtotime($this->getLastModified($path));