--- /dev/null
+Return-Path: <jani@nikula.org>\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 C53F46DE1510\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Sep 2015 02:35:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.502\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.502 tagged_above=-999 required=5 tests=[AWL=0.218,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01]\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 gGoqPBqfY7bA for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Sep 2015 02:35:40 -0700 (PDT)\r
+Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com\r
+ [209.85.212.169])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id CE2216DE1502\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Sep 2015 02:35:39 -0700 (PDT)\r
+Received: by wiclk2 with SMTP id lk2so38787025wic.1\r
+ for <notmuch@notmuchmail.org>; Sat, 05 Sep 2015 02:35:38 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=5aFUv8YoQc3El441ck4fc5uHQKbvulgDow8hGbYtwrc=;\r
+ b=R5CXdX2aNmcQj/TZFQgdbyd0JKdKvHsVylpZihbPmt3/b7rwRvDoFF6LdwWLnNIcn/\r
+ aNCjuIEiakAjLJMChSWOads9+Ktt/TQHKzAO4sq5THo38QBRkdYXu/+BJ0KJhN7bkGW6\r
+ eVVC9zUTvVO/09Ud5FZW1kqzuow5P0yyYW0St+P5OzHtZYgIlqifZg9LyGGU4LxiiN/V\r
+ Nvuu+Meam6IslDuLVlsZm4vcn6Dx/cFt/4mYq9s3o+IIl3EbfTH9gU1jH8W2nKOmd4jx\r
+ Mli+6hnZusSFGj7h4R9dqABrXStLpCGbV0Q0JH4yVRZrxML13+8evP8vXeuFLuu6n4W6\r
+ 94XQ==\r
+X-Gm-Message-State:\r
+ ALoCoQnBHaHK1XgCCaOUEMF9Dglj9IFiswlhb5t5GC/mK5avGHv3DmYyEXjSx79+Soxe/9tKOtWi\r
+X-Received: by 10.194.113.101 with SMTP id ix5mr16644944wjb.66.1441445738003; \r
+ Sat, 05 Sep 2015 02:35:38 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi.\r
+ [188.238.79.131])\r
+ by smtp.gmail.com with ESMTPSA id cm6sm9237118wib.22.2015.09.05.02.35.37\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 05 Sep 2015 02:35:37 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Mark Walters <markwalters1009@gmail.com>,\r
+ notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] cli: reset db directory mtime upon directory removal\r
+Date: Sat, 5 Sep 2015 12:35:31 +0300\r
+Message-Id: <1441445731-4362-2-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1441445731-4362-1-git-send-email-jani@nikula.org>\r
+References: <87siray6th.fsf@qmul.ac.uk>\r
+ <1441445731-4362-1-git-send-email-jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Sat, 05 Sep 2015 09:35:41 -0000\r
+\r
+The library does not have a function to remove a directory document\r
+for a path. Usually this doesn't matter except for a slight waste of\r
+space. However, if the same directory gets added to the filesystem\r
+again, the old directory document is found with the old mtime. Reset\r
+the directory mtime on removal to avoid problems.\r
+\r
+The corner case that can hit this problem is renaming directories back\r
+and forth. Renaming does not change the mtime of the directory in the\r
+filesystem, and thus the old db directory document mtime may match the\r
+fs mtime of the directory.\r
+\r
+The long term fix might be to add a library function to remove a\r
+directory document, however this is a much simpler and faster fix for\r
+the time being.\r
+---\r
+ notmuch-new.c | 9 +++++++++\r
+ 1 file changed, 9 insertions(+)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index 514e06a4d1f3..33645349cd5f 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -878,6 +878,15 @@ _remove_directory (void *ctx,\r
+ goto DONE;\r
+ }\r
+ \r
++ /*\r
++ * XXX: The library does not have a function to remove a directory\r
++ * document for a path. Usually this doesn't matter except for a\r
++ * slight waste of space. However, if the directory gets added to\r
++ * the filesystem again, the old directory document is found with\r
++ * the old mtime. Reset the directory mtime to avoid problems.\r
++ */\r
++ notmuch_directory_set_mtime (directory, 0);\r
++\r
+ DONE:\r
+ notmuch_directory_destroy (directory);\r
+ return status;\r
+-- \r
+2.1.4\r
+\r