Actions
Bug #16285
closedSetting mtime to zero on Zlib::GzipWriter does nothing
Description
Run the following script to observe the issue
require 'zlib'
def write_gzip_file(content, mtime)
File.open('archieve.gz', 'w') do |f|
gz = Zlib::GzipWriter.new(f)
gz.mtime = mtime
gz.write(content)
gz.close
end
system("file archieve.gz")
end
write_gzip_file("current time", 0)
write_gzip_file("one second from epoch", 1)
Output:
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
archieve.gz: gzip compressed data, last modified: Wed Oct 30 18:04:07 2019, from Unix, original size 12
archieve.gz: gzip compressed data, last modified: Thu Jan 1 00:00:01 1970, from Unix, original size 21
As you can see, setting mtime to 0 doesn't set the timestamp in the file header to be all zeros.
The documentation for #mtime=
says:
If you do not set an mtime, the default value will be the time when compression started. Setting a value of 0 indicates no time stamp is available.
which sounds like setting 0 should be a valid operation.
I have a PR to fix this: https://github.com/ruby/zlib/pull/10
Updated by alanwu (Alan Wu) over 5 years ago
- Subject changed from Setting mtime to zero Zlib::GzipWriter does nothing to Setting mtime to zero on Zlib::GzipWriter does nothing
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Status changed from Open to Closed
Actions
Like0
Like0Like0Like0Like0