From: Mark Anderson <ma.skies@gmail.com>
To: Pieter Praet <pieter@praet.org>,
notmuch@notmuchmail.org, cworth@cworth.org
Subject: [PATCH] Fix folder: coherence issue
Date: Wed, 29 Jun 2011 14:04:45 -0600 [thread overview]
Message-ID: <878vskie5p.fsf@gmail.com> (raw)
In-Reply-To: <87iprqxxp6.fsf@praet.org>
Add removal of all ZXFOLDER terms to removal of all XFOLDER terms for
each message filename removal.
The existing filename-list reindexing will put all the needed terms
back in. Test search-folder-coherence now passes.
Signed-off-by:Mark Anderson <ma.skies@gmail.com>
---
Once I fixed the removal instead of the addition side, things went
smoothly.
lib/message.cc | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc
index 8b9c84f..d993cde 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -514,6 +514,8 @@ _notmuch_message_remove_filename (notmuch_message_t *message,
const char *folder_prefix = _find_prefix ("folder");
int folder_prefix_len = strlen (folder_prefix);
void *local = talloc_new (message);
+ char *zfolder_prefix = talloc_asprintf(local, "Z%s", folder_prefix);
+ int zfolder_prefix_len = strlen (zfolder_prefix);
char *direntry;
notmuch_private_status_t private_status;
notmuch_status_t status;
@@ -530,9 +532,12 @@ _notmuch_message_remove_filename (notmuch_message_t *message,
status = COERCE_STATUS (private_status,
"Unexpected error from _notmuch_message_remove_term");
- /* Re-synchronize "folder:" terms for this message. This requires
- * first removing all "folder:" terms, then adding back terms for
- * all remaining filenames of the message. */
+ /* Re-synchronize "folder:" terms for this message. This requires:
+ * 1. removing all "folder:" terms
+ * 2. removing all "folder:" stemmed terms
+ * 3. adding back terms for all remaining filenames of the message. */
+
+ /* 1. removing all "folder:" terms */
while (1) {
i = message->doc.termlist_begin ();
i.skip_to (folder_prefix);
@@ -551,6 +556,26 @@ _notmuch_message_remove_filename (notmuch_message_t *message,
}
}
+ /* 2. removing all "folder:" stemmed terms */
+ while (1) {
+ i = message->doc.termlist_begin ();
+ i.skip_to (zfolder_prefix);
+
+ /* Terminate loop when no terms remain with desired prefix. */
+ if (i == message->doc.termlist_end () ||
+ strncmp ((*i).c_str (), zfolder_prefix, zfolder_prefix_len))
+ {
+ break;
+ }
+
+ try {
+ message->doc.remove_term ((*i));
+ } catch (const Xapian::InvalidArgumentError) {
+ /* Ignore failure to remove non-existent term. */
+ }
+ }
+
+ /* 3. adding back terms for all remaining filenames of the message. */
i = message->doc.termlist_begin ();
i.skip_to (direntry_prefix);
--
1.7.4.1
next prev parent reply other threads:[~2011-06-29 20:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 17:12 [PATCH] test:Folder tags shouldn't match after removal of file in given folder Mark Anderson
2011-06-27 20:58 ` Austin Clements
2011-06-27 22:57 ` Mark Anderson
2011-06-28 6:43 ` Pieter Praet
2011-06-29 20:04 ` Mark Anderson [this message]
2011-06-29 21:16 ` [PATCH] Fix folder: coherence issue Carl Worth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878vskie5p.fsf@gmail.com \
--to=ma.skies@gmail.com \
--cc=cworth@cworth.org \
--cc=notmuch@notmuchmail.org \
--cc=pieter@praet.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).