From 16003e1f8f22a4a1e2a63c89941565ae1a7b320b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 27 Oct 2009 12:00:58 -0700 Subject: Unbreak the "notmuch setup" command. The recent addition of support for automatically adding tags to new messages for "notmuch new" caused "notmuch setup" to segfault. The fix is simple, (just need to move a destroy function to inside a nearby if block). Did I mention recently we need to add a test suite? --- notmuch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'notmuch.c') diff --git a/notmuch.c b/notmuch.c index f620f58..ca30b52 100644 --- a/notmuch.c +++ b/notmuch.c @@ -264,9 +264,10 @@ add_files_recursive (notmuch_database_t *notmuch, /* success */ case NOTMUCH_STATUS_SUCCESS: state->added_messages++; - if (state->callback) + if (state->callback) { (state->callback) (message); - notmuch_message_destroy (message); + notmuch_message_destroy (message); + } break; /* Non-fatal issues (go on to next file) */ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: -- cgit v1.2.3 From 89697201080cd8aa3196792be1d0cae45c782952 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 27 Oct 2009 16:07:27 -0700 Subject: Fix "notmuch new" (bad performance, and no committing of results). We were incorrectly only destroying messages in the case of successful addition to the database, and not in other cases, (such as failure due to FILE_NOT_EMAIL). I'm still not entirely sure why this was performing abysmally, (as in making an operation that should take a small fraction of a second take 10 seconds), nor why it was causing the database to entirely fail to get new results. But fortunately, this all seems to work now. --- notmuch.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'notmuch.c') diff --git a/notmuch.c b/notmuch.c index ca30b52..0fc4433 100644 --- a/notmuch.c +++ b/notmuch.c @@ -180,7 +180,7 @@ add_files_recursive (notmuch_database_t *notmuch, char *next = NULL; time_t path_mtime, path_dbtime; notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS; - notmuch_message_t *message, **closure; + notmuch_message_t *message = NULL, **closure; /* If we're told to, we bail out on encountering a read-only * directory, (with this being a clear clue from the user to @@ -264,10 +264,8 @@ add_files_recursive (notmuch_database_t *notmuch, /* success */ case NOTMUCH_STATUS_SUCCESS: state->added_messages++; - if (state->callback) { + if (state->callback) (state->callback) (message); - notmuch_message_destroy (message); - } break; /* Non-fatal issues (go on to next file) */ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: @@ -292,6 +290,12 @@ add_files_recursive (notmuch_database_t *notmuch, INTERNAL_ERROR ("add_message returned unexpected value: %d", status); goto DONE; } + + if (message) { + notmuch_message_destroy (message); + message = NULL; + } + if (state->processed_files % 1000 == 0) add_files_print_progress (state); } -- cgit v1.2.3