From: XrXr@... Date: 2019-10-30T18:06:24+00:00 Subject: [ruby-core:95590] [Ruby master Bug#16285] Setting mtime to zero Zlib::GzipWriter does nothing Issue #16285 has been reported by alanwu (Alan Wu). ---------------------------------------- Bug #16285: Setting mtime to zero Zlib::GzipWriter does nothing https://bugs.ruby-lang.org/issues/16285 * Author: alanwu (Alan Wu) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Run the following script to observe the issue ```ruby 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) ``` 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. I have a PR to fix this: https://github.com/ruby/zlib/pull/10 -- https://bugs.ruby-lang.org/ Unsubscribe: