]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
lib: add versions of n_q_count_{message,threads} with status return
[notmuch] / lib / database.cc
index dcfad8cf2c67306ea9d956d0af9309db06e78187..f39d4485076cf9e855f6d7fe2401d4b1cf1894b4 100644 (file)
@@ -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;
 }