[PATCHv2] emacs: derive correct timestamp in FCC unique name
authorJesse Rosenthal <jrosenthal@jhu.edu>
Thu, 14 Jun 2012 17:16:03 +0000 (13:16 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:40 +0000 (09:47 -0800)
39/dc2392fc2e55152e3c554b3ec457f863b42a6f [new file with mode: 0644]

diff --git a/39/dc2392fc2e55152e3c554b3ec457f863b42a6f b/39/dc2392fc2e55152e3c554b3ec457f863b42a6f
new file mode 100644 (file)
index 0000000..10b41d5
--- /dev/null
@@ -0,0 +1,100 @@
+Return-Path: <prvs=505a806dc=jrosenthal@jhu.edu>\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 097D6431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 14 Jun 2012 11:16:08 -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 W8YKo5oemgCU for <notmuch@notmuchmail.org>;\r
+       Thu, 14 Jun 2012 11:16:07 -0700 (PDT)\r
+X-Greylist: delayed 3603 seconds by postgrey-1.32 at olra;\r
+       Thu, 14 Jun 2012 11:16:07 PDT\r
+Received: from smtpauth.johnshopkins.edu (smtpauth.johnshopkins.edu\r
+       [128.220.160.201]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 73578431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 14 Jun 2012 11:16:07 -0700 (PDT)\r
+X-IronPort-Anti-Spam-Filtered: true\r
+X-IronPort-Anti-Spam-Result: AkwJAIwb2k8KoSES/2dsb2JhbABFtA0DgjOCGQEFeRAYFAwZDwEsGxm5EIkEjCmBcwyDGwObFwOMfw\r
+X-IronPort-AV: E=Sophos;i="4.75,770,1330923600"; d="scan'208";a="173409136"\r
+Received: from unknown (HELO watt) ([10.161.33.18])\r
+       by ipex4.johnshopkins.edu with ESMTP/TLS/AES256-SHA;\r
+       14 Jun 2012 13:16:01 -0400\r
+Received: from jkr by watt with local (Exim 4.76)\r
+       (envelope-from <jrosenthal@jhu.edu>)\r
+       id 1SfDeN-000304-QQ; Thu, 14 Jun 2012 13:16:03 -0400\r
+From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCHv2] 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.12~rc1 (http://notmuchmail.org) Emacs/24.1.50.1\r
+       (i686-pc-linux-gnu)\r
+Date: Thu, 14 Jun 2012 13:16:03 -0400\r
+Message-ID: <87y5npg6gc.fsf@jhu.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\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 18:16:08 -0000\r
+\r
+\r
+Previously, the timestamp at the beginning of the FCC unique maildir\r
+name was derived incorrectly, thanks to an integer overflow. This\r
+changes the derivation of timestamp to use a float, and so will get\r
+the number correct at least until 2038. (It is still formatted with\r
+"%d" so it will show up as an integer.) Should we need to change it in\r
+the next 26 years to take the unix millenium into account, it will be\r
+invisible to users.\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
+ emacs/notmuch-maildir-fcc.el |    7 +++----\r
+ 1 file changed, 3 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
+index dcfbc4b..07eedba 100644\r
+--- a/emacs/notmuch-maildir-fcc.el\r
++++ b/emacs/notmuch-maildir-fcc.el\r
+@@ -140,13 +140,12 @@ will NOT be removed or replaced."\r
+                           t))\r
\r
+ (defun notmuch-maildir-fcc-make-uniq-maildir-id ()\r
+-   (let* ((ct (current-time))\r
+-        (timeid (+ (* (car ct) 65536) (cadr ct)))\r
+-        (microseconds (car (cdr (cdr ct))))\r
++   (let* ((ftime (float-time))\r
++        (microseconds (mod (* 1000000 ftime) 1000000))\r
+         (hostname (notmuch-maildir-fcc-host-fixer system-name)))\r
+      (setq notmuch-maildir-fcc-count (+ notmuch-maildir-fcc-count 1))\r
+      (format "%d.%d_%d_%d.%s"\r
+-           timeid\r
++           ftime\r
+            (emacs-pid)\r
+            microseconds\r
+            notmuch-maildir-fcc-count\r
+-- \r
+1.7.9.5\r
+\r