Re: [notmuch] [PATCHv2] Preserve folder information when indexing

Subject: Re: [notmuch] [PATCHv2] Preserve folder information when indexing

Date: Tue, 2 Feb 2010 21:43:27 +0100

To: Arvid Picciani


From: Michal Sojka

On Tuesday 02 February 2010 18:48:25 Arvid Picciani wrote:
> On Tue,  2 Feb 2010 16:01:08 +0100, Michal Sojka<>
> wrote:
> > Stores the folder (directory name) of the message in the database as a
> > term with folder prefix.


I've just made several experiments. I tested both Maildir layout (your case)
and non-Maildir layout and both layouts work correctly.

Then I tried to create notmuch database without this patch and then add new mails
and run notmuch new with the patch. It seems that in that case no folder terms
are added to the database. 

Probably DATABASE_VERSION should be increased by this patch, but I do not want
to do it until it is clear that this patch will be merged. Otherwise, there 
might be collision with other patches.
> unfortunately it doesnt do anything here :/
> i rebuilt the entire index, but no folder: field is added.

How did you rebuild it? I deleted the .notmuch directory and run notmuch new.

> can anyone who got it working tell me their directory layout?
> mine would be something like:

If the above didn't help, try to apply this patch. If you see your folder names
during notmuch new, it should work.


---- 8< ------
diff --git a/lib/ b/lib/
index ba2aa16..a22e226 100644
--- a/lib/
+++ b/lib/
@@ -1436,6 +1436,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
            date = notmuch_message_file_get_header (message_file, "date");
            _notmuch_message_set_date (message, date);
+           printf("folder=%s\n", folder_name);
            if (folder_name != NULL)
                _notmuch_message_gen_terms (message, "folder", folder_name);