From f9b4cf417a5c0efae03c3868110b671caadc8399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 22 Feb 2024 11:40:00 +0100 Subject: [PATCH] fix(files): Preserve directory mtime on rename and move 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/Common.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 8be0ae56699..1662d5cc7a2 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -240,6 +240,10 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } closedir($dir); + if ($preserveMtime) { + $mtime = $this->filemtime($source); + $this->touch($target, is_int($mtime) ? $mtime : null); + } return true; } else { $sourceStream = $this->fopen($source, 'r'); @@ -637,6 +641,10 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, $result = $this->copyFromStorage($sourceStorage, $sourceInternalPath . '/' . $file, $targetInternalPath . '/' . $file, $preserveMtime); } } + if ($result && $preserveMtime) { + $mtime = $sourceStorage->filemtime($sourceInternalPath); + $this->touch($targetInternalPath, is_int($mtime) ? $mtime : null); + } } } else { $source = $sourceStorage->fopen($sourceInternalPath, 'r');