From d176d3cd9a55c2c4a643bc7672bbd8a5e2d6d6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 20 Feb 2024 18:20:24 +0100 Subject: [PATCH] fix: Fix mtime preservation on rename in KnownMtime wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/Files/Storage/Wrapper/KnownMtime.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Storage/Wrapper/KnownMtime.php b/lib/private/Files/Storage/Wrapper/KnownMtime.php index dde209c44ab..645a362eefe 100644 --- a/lib/private/Files/Storage/Wrapper/KnownMtime.php +++ b/lib/private/Files/Storage/Wrapper/KnownMtime.php @@ -86,7 +86,7 @@ class KnownMtime extends Wrapper { public function rename($source, $target) { $result = parent::rename($source, $target); if ($result) { - $this->knowMtimes->set($target, $this->clock->now()->getTimestamp()); + $this->knowMtimes->set($target, $this->filemtime($source)); $this->knowMtimes->set($source, $this->clock->now()->getTimestamp()); } return $result; @@ -125,9 +125,10 @@ class KnownMtime extends Wrapper { } public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + $mTime = $sourceStorage->filemtime($sourceInternalPath); $result = parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); if ($result) { - $this->knowMtimes->set($targetInternalPath, $this->clock->now()->getTimestamp()); + $this->knowMtimes->set($targetInternalPath, $mTime); } return $result; }