X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=f39d4485076cf9e855f6d7fe2401d4b1cf1894b4;hp=dcfad8cf2c67306ea9d956d0af9309db06e78187;hb=87ee9a53e36f395e73e16da12cb268a708147259;hpb=81bd41c7cb59a8d70932e6bdbee6e1e2cde5477f diff --git a/lib/database.cc b/lib/database.cc index dcfad8cf..f39d4485 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1410,8 +1410,15 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_BOOL_FOLDER | NOTMUCH_FEATURE_LAST_MOD)) { query = notmuch_query_create (notmuch, ""); - total += notmuch_query_count_messages (query); + unsigned msg_count; + + status = notmuch_query_count_messages_st (query, &msg_count); + if (status) + goto DONE; + + total += msg_count; notmuch_query_destroy (query); + query = NULL; } if (new_features & NOTMUCH_FEATURE_DIRECTORY_DOCS) { t_end = db->allterms_end ("XTIMESTAMP"); @@ -1492,6 +1499,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, } notmuch_query_destroy (query); + query = NULL; } /* Perform per-directory upgrades. */ @@ -1612,6 +1620,9 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, sigaction (SIGALRM, &action, NULL); } + if (query) + notmuch_query_destroy (query); + talloc_free (local); return status; }