From a493fa17d59c93161f0cb708a285d154ed86487d Mon Sep 17 00:00:00 2001 From: donoghuc Date: Wed, 3 Sep 2025 14:23:00 -0700 Subject: [PATCH 1/2] Ensure any file object in a tar archive has an mtime Following up on https://github.com/elastic/logstash/pull/18091, when minitar writes a directory or symlink it also needs explicit mtime. After inspecting artifacts built from #18019 we see some other missing mtimes. This commit ensures that information is explicitly passed to the minitar writer. --- rakelib/artifacts.rake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rakelib/artifacts.rake b/rakelib/artifacts.rake index 619a97325d..0ebf56c8d6 100644 --- a/rakelib/artifacts.rake +++ b/rakelib/artifacts.rake @@ -664,12 +664,13 @@ namespace "artifact" do def write_to_tar(tar, path, path_in_tar) stat = File.lstat(path) + mtime = (stat.mtime || Time.now).to_i if stat.directory? - tar.mkdir(path_in_tar, :mode => stat.mode) + tar.mkdir(path_in_tar, :mode => stat.mode, :mtime => mtime) elsif stat.symlink? - tar.symlink(path_in_tar, File.readlink(path), :mode => stat.mode) + tar.symlink(path_in_tar, File.readlink(path), :mode => stat.mode, :mtime => mtime) else - tar.add_file_simple(path_in_tar, :mode => stat.mode, :size => stat.size, :mtime => (stat.mtime || Time.now).to_i) do |io| + tar.add_file_simple(path_in_tar, :mode => stat.mode, :size => stat.size, :mtime => mtime) do |io| File.open(path, 'rb') do |fd| chunk = nil size = 0 From b95eded54ab34c8819511b476dabe0a601646582 Mon Sep 17 00:00:00 2001 From: Cas Donoghue Date: Thu, 4 Sep 2025 09:06:55 -0700 Subject: [PATCH 2/2] Update rakelib/artifacts.rake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Duarte --- rakelib/artifacts.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/rakelib/artifacts.rake b/rakelib/artifacts.rake index 0ebf56c8d6..87a57d262b 100644 --- a/rakelib/artifacts.rake +++ b/rakelib/artifacts.rake @@ -664,6 +664,7 @@ namespace "artifact" do def write_to_tar(tar, path, path_in_tar) stat = File.lstat(path) + # in the off-chance that mtime returns nil we don't want nil to be interpreted as epoch, so fall back to Time.now mtime = (stat.mtime || Time.now).to_i if stat.directory? tar.mkdir(path_in_tar, :mode => stat.mode, :mtime => mtime)