From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 873DF1F4C0 for ; Wed, 30 Oct 2019 18:06:34 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 910631209E8; Thu, 31 Oct 2019 03:06:23 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 3AD761208D0 for ; Thu, 31 Oct 2019 03:06:21 +0900 (JST) Received: by filter0036p3iad2.sendgrid.net with SMTP id filter0036p3iad2-766-5DB9D120-29 2019-10-30 18:06:24.280046266 +0000 UTC m=+153841.012445140 Received: from herokuapp.com (unknown [18.215.166.206]) by ismtpd0080p1mdw1.sendgrid.net (SG) with ESMTP id sxhIkZf4QvGU9dGt17jKvw for ; Wed, 30 Oct 2019 18:06:24.297 +0000 (UTC) Date: Wed, 30 Oct 2019 18:06:24 +0000 (UTC) From: XrXr@users.noreply.github.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71183 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16285 X-Redmine-Issue-Author: alanwu X-Redmine-Sender: alanwu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?PWg67P6owy8ojUUZg1G=2FQM4Z0jTQ2XLCqLM8Y2L8tUvRFuUPM6+aKANjRFY5CJ?= =?us-ascii?Q?rIULEmnCK2avF1RBpjgcRj89HaS59opjNdi6FLX?= =?us-ascii?Q?cbFcC5RMQhWSMfuLOcO9418LSbjbW1p=2FIv7IzjD?= =?us-ascii?Q?5XJWcoUSZev4d8Ab0JC221A+nlGIynZPJ0cW1sF?= =?us-ascii?Q?jL0IPeO16DE2MRUA50rDzuc19Ysw=2F87kQ4w=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95590 Subject: [ruby-core:95590] [Ruby master Bug#16285] Setting mtime to zero Zlib::GzipWriter does nothing X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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/