From 899330a01056077271e2f614c7b28b0379a671eb Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 21 Mar 2024 08:49:09 +0100 Subject: [PATCH] preserve the file modification time when mirroring directories --- Filesystem.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Filesystem.php b/Filesystem.php index 4df06aed1..909810f98 100644 --- a/Filesystem.php +++ b/Filesystem.php @@ -72,6 +72,9 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe // Like `cp`, preserve executable permission bits self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111)); + // Like `cp`, preserve the file modification time + self::box('touch', $targetFile, filemtime($originFile)); + if ($bytesCopied !== $bytesOrigin = filesize($originFile)) { throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile); }