Skip to content

Commit

Permalink
bug #54362 [Filesystem] preserve the file modification time when mirr…
Browse files Browse the repository at this point in the history
…oring 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
  • Loading branch information
fabpot committed Mar 21, 2024
2 parents 914ce1e + d232026 commit afc658d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit afc658d

Please sign in to comment.