aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2015-09-05 12:35:31 +0300
committerDavid Bremner <david@tethera.net>2015-09-07 09:28:00 -0300
commitacd66cdec075312944e527febd46382e54d99367 (patch)
treefe78988c6b4cbb9d4cb537653e3c4778a9b92604
parent9a5143abbcfbb008f846329b5c50b9322af5322a (diff)
cli: reset db directory mtime upon directory removal
The library does not have a function to remove a directory document for a path. Usually this doesn't matter except for a slight waste of space. However, if the same directory gets added to the filesystem again, the old directory document is found with the old mtime. Reset the directory mtime on removal to avoid problems. The corner case that can hit this problem is renaming directories back and forth. Renaming does not change the mtime of the directory in the filesystem, and thus the old db directory document mtime may match the fs mtime of the directory. The long term fix might be to add a library function to remove a directory document, however this is a much simpler and faster fix for the time being.
-rw-r--r--notmuch-new.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/notmuch-new.c b/notmuch-new.c
index 514e06a4..33645349 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -878,6 +878,15 @@ _remove_directory (void *ctx,
goto DONE;
}
+ /*
+ * XXX: The library does not have a function to remove a directory
+ * document for a path. Usually this doesn't matter except for a
+ * slight waste of space. However, if the directory gets added to
+ * the filesystem again, the old directory document is found with
+ * the old mtime. Reset the directory mtime to avoid problems.
+ */
+ notmuch_directory_set_mtime (directory, 0);
+
DONE:
notmuch_directory_destroy (directory);
return status;