Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit afc658d

Browse filesBrowse files
committed
bug #54362 [Filesystem] preserve the file modification time when mirroring directories (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Filesystem] preserve the file modification time when mirroring directories | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #54327 | License | MIT Commits ------- d232026 preserve the file modification time when mirroring directories
2 parents 914ce1e + d232026 commit afc658d
Copy full SHA for afc658d

File tree

1 file changed

+3
-0
lines changed
Filter options

1 file changed

+3
-0
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
7272
// Like `cp`, preserve executable permission bits
7373
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
7474

75+
// Like `cp`, preserve the file modification time
76+
self::box('touch', $targetFile, filemtime($originFile));
77+
7578
if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
7679
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);
7780
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.