new: Add all initial tags at once

If there are several tags applied to the new messages, it is beneficial
to store them to the database at one, because it saves some time,
especially when the notmuch new is run for the first time.

This patch decreased the time for initial import from 1h 35m to 1h 14m.
This commit is contained in:
Michal Sojka 2011-01-21 10:59:36 +01:00 committed by Carl Worth
parent de2acbd49c
commit 7c450905e4

View file

@ -418,10 +418,12 @@ add_files_recursive (notmuch_database_t *notmuch,
/* success */ /* success */
case NOTMUCH_STATUS_SUCCESS: case NOTMUCH_STATUS_SUCCESS:
state->added_messages++; state->added_messages++;
notmuch_message_freeze (message);
for (tag=state->new_tags; *tag != NULL; tag++) for (tag=state->new_tags; *tag != NULL; tag++)
notmuch_message_add_tag (message, *tag); notmuch_message_add_tag (message, *tag);
if (state->synchronize_flags == TRUE) if (state->synchronize_flags == TRUE)
notmuch_message_maildir_flags_to_tags (message); notmuch_message_maildir_flags_to_tags (message);
notmuch_message_thaw (message);
break; break;
/* Non-fatal issues (go on to next file) */ /* Non-fatal issues (go on to next file) */
case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: