--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 498466DE014D\r
+ for <notmuch@notmuchmail.org>; Mon, 27 Jun 2016 13:43:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.005\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5\r
+ tests=[AWL=-0.006, HEADER_FROM_DIFFERENT_DOMAINS=0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id rEoYwybtVG9H for <notmuch@notmuchmail.org>;\r
+ Mon, 27 Jun 2016 13:43:12 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 52E386DE00CC\r
+ for <notmuch@notmuchmail.org>; Mon, 27 Jun 2016 13:43:11 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1bHdMr-0006WM-6H; Mon, 27 Jun 2016 16:42:53 -0400\r
+Received: (nullmailer pid 25052 invoked by uid 1000);\r
+ Mon, 27 Jun 2016 20:43:07 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: [PATCH] lib: update cached mtime in notmuch_directory_set_mtime\r
+Date: Mon, 27 Jun 2016 22:43:04 +0200\r
+Message-Id: <1467060184-25007-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <87k2hyxg5w.fsf@tesseract.cs.unb.ca>\r
+References: <87k2hyxg5w.fsf@tesseract.cs.unb.ca>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 27 Jun 2016 20:43:20 -0000\r
+\r
+Without this change, the following code fails\r
+\r
+ notmuch_directory_set_mtime(dir, 12345);\r
+ assert(notmuch_directory_get_mtime(dir) == 12345);\r
+---\r
+ lib/directory.cc | 3 +++\r
+ 1 file changed, 3 insertions(+)\r
+\r
+diff --git a/lib/directory.cc b/lib/directory.cc\r
+index a19f777..5de3319 100644\r
+--- a/lib/directory.cc\r
++++ b/lib/directory.cc\r
+@@ -227,6 +227,9 @@ notmuch_directory_set_mtime (notmuch_directory_t *directory,\r
+ Xapian::sortable_serialise (mtime));\r
+ \r
+ db->replace_document (directory->document_id, directory->doc);\r
++\r
++ directory->mtime = mtime;\r
++\r
+ } catch (const Xapian::Error &error) {\r
+ _notmuch_database_log (notmuch,\r
+ "A Xapian exception occurred setting directory mtime: %s.\n",\r
+-- \r
+2.8.1\r
+\r