[PATCH 3/3] cli: delete directory documents on directory removal

Jani Nikula jani at nikula.org
Fri Sep 25 13:48:46 PDT 2015


There was a problem with the directory documents being left behind
when the filesystem directory was removed. This was worked around in

commit acd66cdec075312944e527febd46382e54d99367
Author: Jani Nikula <jani at nikula.org>
Date:   Sat Sep 5 12:35:31 2015 +0300

    cli: reset db directory mtime upon directory removal

However, that ignored the fact that the directory documents are also
still listed by notmuch_directory_get_child_directories() leading to
confusing results when running notmuch new. The directory documents
are found and queued for removal over and over again.

Fix the problem for real by removing the directory documents. This
fixes the tests flagged as broken in

commit ed9ceda623d3f22fb66365b33db63c5c982067d3
Author: David Bremner <david at tethera.net>
Date:   Tue Aug 4 08:48:34 2015 +0200

    test: add debugging output to notmuch-new tests, mark 5 as broken

The (non-deterministic) hack test from [1] also still passes with this
change.

[1] id:1441445731-4362-1-git-send-email-jani at nikula.org
---
 notmuch-new.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 33645349cd5f..8bfed37fef96 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -878,17 +878,11 @@ _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);
+    status = notmuch_directory_delete (directory);
 
   DONE:
-    notmuch_directory_destroy (directory);
+    if (status)
+	notmuch_directory_destroy (directory);
     return status;
 }
 
-- 
2.1.4



More information about the notmuch mailing list