From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 038616DE1271 for ; Sat, 10 Oct 2015 05:30:01 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.105 X-Spam-Level: X-Spam-Status: No, score=0.105 tagged_above=-999 required=5 tests=[AWL=0.105] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x2bikh0Zri6b for ; Sat, 10 Oct 2015 05:29:59 -0700 (PDT) Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224]) by arlo.cworth.org (Postfix) with ESMTPS id 0E1E26DE1502 for ; Sat, 10 Oct 2015 05:29:59 -0700 (PDT) Received: from remotemail by gitolite.debian.net with local (Exim 4.80) (envelope-from ) id 1ZktGF-0008Av-01; Sat, 10 Oct 2015 12:28:26 +0000 Received: (nullmailer pid 8598 invoked by uid 1000); Sat, 10 Oct 2015 12:27:30 -0000 From: David Bremner To: Jani Nikula , notmuch@notmuchmail.org Subject: [PATCH 3/3] cli: delete directory documents on directory removal Date: Sat, 10 Oct 2015 09:27:19 -0300 Message-Id: <1444480039-8530-4-git-send-email-david@tethera.net> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1444480039-8530-1-git-send-email-david@tethera.net> References: <591f5298ac3f2c79f727cac8bad1251830b28a3c.1443213654.git.jani@nikula.org> <1444480039-8530-1-git-send-email-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Oct 2015 12:30:01 -0000 From: Jani Nikula There was a problem with the directory documents being left behind when the filesystem directory was removed. This was worked around in [1]. 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 [2]. The (non-deterministic) hack test from [1] also still passes with this change. [1] commit acd66cdec075312944e527febd46382e54d99367 [2] commit ed9ceda623d3f22fb66365b33db63c5c982067d3 [3] id:1441445731-4362-1-git-send-email-jani@nikula.org --- notmuch-new.c | 12 +++--------- test/T050-new.sh | 6 ------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 442a2f0..d45d0af 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; } diff --git a/test/T050-new.sh b/test/T050-new.sh index 33ce1ab..81cf2fa 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -93,7 +93,6 @@ No new mail. Detected 3 file renames." test_begin_subtest "Deleted directory" -test_subtest_known_broken rm -rf "${MAIL_DIR}"/dir-renamed output=$(NOTMUCH_NEW --debug) @@ -102,7 +101,6 @@ No new mail. Removed 3 messages." test_begin_subtest "New directory (at end of list)" -test_subtest_known_broken generate_message [dir]=zzz generate_message [dir]=zzz @@ -114,7 +112,6 @@ test_expect_equal "$output" "Added 3 new messages to the database." test_begin_subtest "Deleted directory (end of list)" -test_subtest_known_broken rm -rf "${MAIL_DIR}"/zzz output=$(NOTMUCH_NEW --debug) @@ -173,7 +170,6 @@ test_expect_equal "$output" "(D) add_files_recursive, pass 3: queuing leftover d No new mail. Removed 3 messages." test_begin_subtest "Support single-message mbox" -test_subtest_known_broken cat > "${MAIL_DIR}"/mbox_file1 < @@ -187,7 +183,6 @@ test_expect_equal "$output" "Added 1 new message to the database." # This test requires that notmuch new has been run at least once. test_begin_subtest "Skip and report non-mail files" -test_subtest_known_broken generate_message mkdir -p "${MAIL_DIR}"/.git && touch "${MAIL_DIR}"/.git/config touch "${MAIL_DIR}"/ignored_file @@ -224,7 +219,6 @@ output=$(NOTMUCH_NEW 2>&1) test_expect_equal "$output" "Added 1 new message to the database." test_begin_subtest "Ignore files and directories specified in new.ignore (multiple occurrences)" -test_subtest_known_broken notmuch config set new.ignore .git ignored_file .ignored_hidden_file notmuch new > /dev/null # ensure that files/folders will be printed in ASCII order. touch "${MAIL_DIR}"/.git # change .git's mtime for notmuch new to rescan. -- 2.5.3