Skip to content

Commit d9b95bf

Browse files
donoghucjsvd
andauthored
Preserve mtime explicitly when creating tar artifacts (#18091)
* Preserve mtime explicitly when creating tar artifacts When building tar archives, explicitly set mtime. This avoids losing that information in the minitar `Writer.add_file_simple` method https://github.com/halostatue/minitar/blob/a531136b17b9efdddf0a0f39537845b454c2371e/lib/minitar/writer.rb#L139 * Better default for mtime If for some reason we cant get a time from a File object (very unlikely) a better default is Time.now rather than 0. * Update rakelib/artifacts.rake Co-authored-by: João Duarte <[email protected]> --------- Co-authored-by: João Duarte <[email protected]>
1 parent 23d06e6 commit d9b95bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rakelib/artifacts.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ namespace "artifact" do
669669
elsif stat.symlink?
670670
tar.symlink(path_in_tar, File.readlink(path), :mode => stat.mode)
671671
else
672-
tar.add_file_simple(path_in_tar, :mode => stat.mode, :size => stat.size) do |io|
672+
tar.add_file_simple(path_in_tar, :mode => stat.mode, :size => stat.size, :mtime => (stat.mtime || Time.now).to_i) do |io|
673673
File.open(path, 'rb') do |fd|
674674
chunk = nil
675675
size = 0

0 commit comments

Comments
 (0)