* [ruby-core:95590] [Ruby master Bug#16285] Setting mtime to zero Zlib::GzipWriter does nothing
[not found] <redmine.issue-16285.20191030180623@ruby-lang.org>
@ 2019-10-30 18:06 ` XrXr
0 siblings, 0 replies; only message in thread
From: XrXr @ 2019-10-30 18:06 UTC (permalink / raw)
To: ruby-core
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/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-10-30 18:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-16285.20191030180623@ruby-lang.org>
2019-10-30 18:06 ` [ruby-core:95590] [Ruby master Bug#16285] Setting mtime to zero Zlib::GzipWriter does nothing XrXr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).