Merge pull request #14723 from carlocab/zlib-mtime

utils/gzip: set `mtime = 1` when `mtime == 0`.
This commit is contained in:
Mike McQuaid 2023-02-21 09:04:55 +00:00 committed by GitHub
commit f0fbeba2ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,11 +28,11 @@ module Utils
# Zlib::GzipWriter does not properly handle the case of setting mtime = 0:
# https://bugs.ruby-lang.org/issues/16285
#
# This was fixed in https://github.com/ruby/zlib/pull/10. Set mtime to 0 instead
# of raising exception once we are using zlib gem version 1.1.0 or newer.
# This was fixed in https://github.com/ruby/zlib/pull/10. Remove workaround
# once we are using zlib gem version 1.1.0 or newer.
if mtime.to_i.zero?
raise ArgumentError,
"Can't create reproducible gzip file without a valid mtime"
odebug "Setting `mtime = 1` to avoid zlib gem bug when `mtime == 0`."
mtime = 1
end
File.open(path, "rb") do |fp|