aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/database.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2011-01-15 14:09:04 -0800
committerGravatar Carl Worth <cworth@cworth.org>2011-01-15 15:37:43 -0800
commit99cfa2703080c2474e6b8aec0cae86135ae23f1d (patch)
tree21d73e4d926f9277d6ece1f111259e9066f85bce /lib/database.cc
parent600f3761dc48c91a5ba9a18ddeb7fd8af22e71de (diff)
Add support for folder-based searching.
A new "folder:" prefix in the query string can now be used to match the directories in which mail files are stored. The addition of this feature causes the recently added search-by-folder tests to now pass.
Diffstat (limited to 'lib/database.cc')
-rw-r--r--lib/database.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/database.cc b/lib/database.cc
index 289e41c4..d88b168b 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -89,8 +89,9 @@ typedef struct {
*
* In addition, terms from the content of the message are added with
* "from", "to", "attachment", and "subject" prefixes for use by the
- * user in searching. But the database doesn't really care itself
- * about any of these.
+ * user in searching. Similarly, terms from the path of the mail
+ * message are added with a "folder" prefix. But the database doesn't
+ * really care itself about any of these.
*
* The data portion of a mail document is empty.
*
@@ -204,7 +205,8 @@ static prefix_t PROBABILISTIC_PREFIX[]= {
{ "from", "XFROM" },
{ "to", "XTO" },
{ "attachment", "XATTACHMENT" },
- { "subject", "XSUBJECT"}
+ { "subject", "XSUBJECT"},
+ { "folder", "XFOLDER"}
};
int
@@ -1716,11 +1718,20 @@ notmuch_database_remove_message (notmuch_database_t *notmuch,
for ( ; i != end; i++) {
Xapian::TermIterator j;
+ notmuch_message_t *message;
+ notmuch_private_status_t private_status;
- document = find_document_for_doc_id (notmuch, *i);
+ message = _notmuch_message_create (local, notmuch,
+ *i, &private_status);
+ if (message == NULL)
+ return COERCE_STATUS (private_status,
+ "Inconsistent document ID in datbase.");
- document.remove_term (term);
+ _notmuch_message_remove_filename (message, filename);
+ _notmuch_message_sync (message);
+ /* Take care to find document after sync'ing filename removal. */
+ document = find_document_for_doc_id (notmuch, *i);
j = document.termlist_begin ();
j.skip_to (prefix);
@@ -1731,7 +1742,6 @@ notmuch_database_remove_message (notmuch_database_t *notmuch,
db->delete_document (document.get_docid ());
status = NOTMUCH_STATUS_SUCCESS;
} else {
- db->replace_document (document.get_docid (), document);
status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
}
}