Re: [PATCH] emacs: derive correct timestamp in FCC unique name
authorTomi Ollila <tomi.ollila@iki.fi>
Thu, 14 Jun 2012 09:43:37 +0000 (12:43 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:40 +0000 (09:47 -0800)
6d/189eac5bc63cb29f12e1283c6458f8912aaef4 [new file with mode: 0644]

diff --git a/6d/189eac5bc63cb29f12e1283c6458f8912aaef4 b/6d/189eac5bc63cb29f12e1283c6458f8912aaef4
new file mode 100644 (file)
index 0000000..e7d4377
--- /dev/null
@@ -0,0 +1,125 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 77B96431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 14 Jun 2012 02:43:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id AujDY1loonF7 for <notmuch@notmuchmail.org>;\r
+       Thu, 14 Jun 2012 02:43:28 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id D233C431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 14 Jun 2012 02:43:27 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id 352581000D0; Thu, 14 Jun 2012 12:43:37 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Jesse Rosenthal <jrosenthal@jhu.edu>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: derive correct timestamp in FCC unique name\r
+In-Reply-To: <87d353ezyw.fsf@jhu.edu>\r
+References: <87d353ezyw.fsf@jhu.edu>\r
+User-Agent: Notmuch/0.13.2+7~g2fb5bbc (http://notmuchmail.org) Emacs/23.1.1\r
+       (x86_64-redhat-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Thu, 14 Jun 2012 12:43:37 +0300\r
+Message-ID: <m2k3zamdo6.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 14 Jun 2012 09:43:29 -0000\r
+\r
+On Wed, Jun 13 2012, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:\r
+\r
+> Previously, the timestamp at the beginning of the FCC maildir unique\r
+> maildir name was derived incorrectly, thanks to an integer\r
+> overflow. This changes the derivation of timestamp to float\r
+> arithmetic, and so gets the number correct. (It is still formatted\r
+> with "%d" so it will show up as an integer.)\r
+>\r
+> This change is mostly a question of consistency, since the unique name\r
+> is arbitrary anyway. But since most people use timestamps, and that was\r
+> the original intention here as well, we might as well.\r
+>\r
+> Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+> ---\r
+\r
+Good point -- did some experiments (on 32bit machine, on 64 (* 65536 *65536)\r
+just works OK (4294967296).\r
+\r
+(insert (format " %d" (* 8191 65536)))  536805376\r
+(insert (format " %d" (* 8192 65536)))  -536870912\r
+\r
+Wraps now (many times already)\r
+\r
+(insert (format "  %d" (* 32767 65536.0)))  2147418112\r
+(insert (format "  %d" (* 32768 65536.0)))  -2147483648\r
+\r
+Wraps Tue Jan 19 03:14:08 2038 UTC\r
+\r
+(insert (format "  %0.f" (* 32768 65536.0)))  2147483648\r
+(insert (format "  %0.f" (* 65536 65536.0)))  4294967296\r
+\r
+Does not wrap.\r
+\r
+On emacs window you can re-experiment by typing C-x C-e after last \r
+closing ')' on line.\r
+\r
+(float-time '(32767 65536)) -> 2147418112.0 (minibuffer output)\r
+(float-time '(32768 65536)) -> error "Invalid time specification"\r
+\r
+On 64-bit machine this latest work ok; i.e 2147483648.0 is returned.\r
+\r
+Alternatives:\r
+\r
+1) Use current patch, filenames will have extra '-' in 2038 on 32-bit\r
+systems.\r
+\r
+2) Drop 'timeid' and replace it with (float-time) in `format` call a few\r
+lines in original source after the patch context below -- No idea\r
+how (float-time) works on 32-bit systems after 2038.\r
+\r
+3) Use "%0.f" in format string instead of "%d" (there is no "%ld" or "%u"\r
+sequences for `format`. I wonder what (current-time-string) in current\r
+emacs return in 2038 (maybe I test (sometime(tm)) with (lib)faketime). \r
+\r
+I suggest option #2.\r
+\r
+Tomi\r
+\r
+>  emacs/notmuch-maildir-fcc.el |    2 +-\r
+>  1 file changed, 1 insertion(+), 1 deletion(-)\r
+>\r
+> diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
+> index dcfbc4b..6fd8ff9 100644\r
+> --- a/emacs/notmuch-maildir-fcc.el\r
+> +++ b/emacs/notmuch-maildir-fcc.el\r
+> @@ -141,7 +141,7 @@ will NOT be removed or replaced."\r
+>  \r
+>  (defun notmuch-maildir-fcc-make-uniq-maildir-id ()\r
+>     (let* ((ct (current-time))\r
+> -      (timeid (+ (* (car ct) 65536) (cadr ct)))\r
+> +      (timeid (+ (* (car ct) 65536.0) (cadr ct)))\r
+>        (microseconds (car (cdr (cdr ct))))\r
+>        (hostname (notmuch-maildir-fcc-host-fixer system-name)))\r
+>       (setq notmuch-maildir-fcc-count (+ notmuch-maildir-fcc-count 1))\r
+> -- \r
+> 1.7.9.5\r