From 06b59b500214af35ad7076bb0077fc2231f90c0f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 15 Oct 2021 16:02:57 +0200 Subject: [PATCH] more reliable hasUpdated for s3 Signed-off-by: Robin Appelman --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 230ea10121f..e1383b8404c 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -724,4 +724,17 @@ class AmazonS3 extends \OC\Files\Storage\Common { } return $this->versioningEnabled; } + + public function hasUpdated($path, $time) { + // for files we can get the proper mtime + if ($path !== '' && $object = $this->headObject($path)) { + $stat = $this->objectToMetaData($object); + return $stat['mtime'] > $time; + } else { + // for directories, the only real option we have is to do a prefix listing and iterate over all objects + // however, since this is just as expensive as just re-scanning the directory, we can simply return true + // and have the scanner figure out if anything has actually changed + return true; + } + } }