[PATCH] Fix folder: coherence issue
authorMark Anderson <ma.skies@gmail.com>
Wed, 29 Jun 2011 20:04:45 +0000 (14:04 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:50 +0000 (09:38 -0800)
e7/031aa159548bb1697959cf9640509fd484d038 [new file with mode: 0644]

diff --git a/e7/031aa159548bb1697959cf9640509fd484d038 b/e7/031aa159548bb1697959cf9640509fd484d038
new file mode 100644 (file)
index 0000000..5b1b22f
--- /dev/null
@@ -0,0 +1,136 @@
+Return-Path: <ma.skies@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id DC6D942119B\r
+       for <notmuch@notmuchmail.org>; Wed, 29 Jun 2011 13:19:34 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id Wz9t0-mK1uVB for <notmuch@notmuchmail.org>;\r
+       Wed, 29 Jun 2011 13:19:34 -0700 (PDT)\r
+Received: from mail-iw0-f181.google.com (mail-iw0-f181.google.com\r
+       [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 1682B421192\r
+       for <notmuch@notmuchmail.org>; Wed, 29 Jun 2011 13:19:34 -0700 (PDT)\r
+Received: by iwn37 with SMTP id 37so1501294iwn.26\r
+       for <notmuch@notmuchmail.org>; Wed, 29 Jun 2011 13:19:33 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:in-reply-to:date:references:user-agent:message-id\r
+       :mime-version:content-type;\r
+       bh=ENjO6I2qYFPPIaPDbf3VByFnzPJZ0BWxyH+mjSUaHMk=;\r
+       b=dMmirqkfYiJfTAp076iIOOQE9RmiKKfzyr/JzW1mC+EOpnEBKhAlHdecGt0+eRJV6z\r
+       /4Oc2dPn01bZOJlEUJD/uYnLkXrBrWvdlvbXjll9s7T+B/Q5+GQlARl8NeislRXNlYA8\r
+       3pMHKf/dtI8Zbl0NeODcoJRUETmcy9u0mBBBE=\r
+Received: by 10.42.71.85 with SMTP id i21mr1134475icj.323.1309378773485;\r
+       Wed, 29 Jun 2011 13:19:33 -0700 (PDT)\r
+Received: from localhost ([74.205.145.146])\r
+       by mx.google.com with ESMTPS id f13sm774812ibe.61.2011.06.29.13.19.32\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Wed, 29 Jun 2011 13:19:32 -0700 (PDT)\r
+From: Mark Anderson <ma.skies@gmail.com>\r
+To: Pieter Praet <pieter@praet.org>, notmuch@notmuchmail.org,\r
+ cworth@cworth.org\r
+Subject: [PATCH] Fix folder: coherence issue\r
+In-Reply-To: <87iprqxxp6.fsf@praet.org>\r
+Date: Wed, 29 Jun 2011 14:04:45 -0600\r
+References: <87sjqvw64n.fsf@gmail.com> <87iprqxxp6.fsf@praet.org>\r
+User-Agent: Notmuch/0.5-283-gb744eac (http://notmuchmail.org) Emacs/23.2.1\r
+       (i686-pc-linux-gnu)\r
+Message-ID: <878vskie5p.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Wed, 29 Jun 2011 20:19:35 -0000\r
+\r
+Add removal of all ZXFOLDER terms to removal of all XFOLDER terms for\r
+each message filename removal.\r
+\r
+The existing filename-list reindexing will put all the needed terms\r
+back in.  Test search-folder-coherence now passes.\r
+\r
+Signed-off-by:Mark Anderson <ma.skies@gmail.com>\r
+---\r
+\r
+Once I fixed the removal instead of the addition side, things went\r
+smoothly.\r
+\r
+ lib/message.cc |   31 ++++++++++++++++++++++++++++---\r
+ 1 files changed, 28 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index 8b9c84f..d993cde 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -514,6 +514,8 @@ _notmuch_message_remove_filename (notmuch_message_t *message,\r
+     const char *folder_prefix = _find_prefix ("folder");\r
+     int folder_prefix_len = strlen (folder_prefix);\r
+     void *local = talloc_new (message);\r
++    char *zfolder_prefix = talloc_asprintf(local, "Z%s", folder_prefix);\r
++    int zfolder_prefix_len = strlen (zfolder_prefix);\r
+     char *direntry;\r
+     notmuch_private_status_t private_status;\r
+     notmuch_status_t status;\r
+@@ -530,9 +532,12 @@ _notmuch_message_remove_filename (notmuch_message_t *message,\r
+     status = COERCE_STATUS (private_status,\r
+                           "Unexpected error from _notmuch_message_remove_term");\r
\r
+-    /* Re-synchronize "folder:" terms for this message. This requires\r
+-     * first removing all "folder:" terms, then adding back terms for\r
+-     * all remaining filenames of the message. */\r
++    /* Re-synchronize "folder:" terms for this message. This requires:\r
++     *  1. removing all "folder:" terms\r
++     *  2. removing all "folder:" stemmed terms\r
++     *  3. adding back terms for all remaining filenames of the message. */\r
++\r
++    /* 1. removing all "folder:" terms */\r
+     while (1) {\r
+       i = message->doc.termlist_begin ();\r
+       i.skip_to (folder_prefix);\r
+@@ -551,6 +556,26 @@ _notmuch_message_remove_filename (notmuch_message_t *message,\r
+       }\r
+     }\r
\r
++    /* 2. removing all "folder:" stemmed terms */\r
++    while (1) {\r
++      i = message->doc.termlist_begin ();\r
++      i.skip_to (zfolder_prefix);\r
++\r
++      /* Terminate loop when no terms remain with desired prefix. */\r
++      if (i == message->doc.termlist_end () ||\r
++          strncmp ((*i).c_str (), zfolder_prefix, zfolder_prefix_len))\r
++      {\r
++          break;\r
++      }\r
++\r
++      try {\r
++          message->doc.remove_term ((*i));\r
++      } catch (const Xapian::InvalidArgumentError) {\r
++          /* Ignore failure to remove non-existent term. */\r
++      }\r
++    }\r
++\r
++    /* 3. adding back terms for all remaining filenames of the message. */\r
+     i = message->doc.termlist_begin ();\r
+     i.skip_to (direntry_prefix);\r
\r
+-- \r
+1.7.4.1\r