]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-new.c
debian: add notmuch_query_set_omit_excluded to symbols file.
[notmuch] / notmuch-new.c
index bf9b120949b6697650a681eb5c566b0e97bbfccb..cb720cc2f9a76d36fd8a4194fd9d9dc07f3029f5 100644 (file)
@@ -779,7 +779,8 @@ remove_filename (notmuch_database_t *notmuch,
        return status;
     status = notmuch_database_find_message_by_filename (notmuch, path, &message);
     if (status || message == NULL)
-       return status;
+       goto DONE;
+
     status = notmuch_database_remove_message (notmuch, path);
     if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
        add_files_state->renamed_messages++;
@@ -790,6 +791,8 @@ remove_filename (notmuch_database_t *notmuch,
        add_files_state->removed_messages++;
     }
     notmuch_message_destroy (message);
+
+  DONE:
     notmuch_database_end_atomic (notmuch);
     return status;
 }
@@ -897,12 +900,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
            return 1;
 
        printf ("Found %d total files (that's not much mail).\n", count);
-       notmuch = notmuch_database_create (db_path);
+       if (notmuch_database_create (db_path, &notmuch))
+           return 1;
        add_files_state.total_files = count;
     } else {
-       notmuch = notmuch_database_open (db_path,
-                                        NOTMUCH_DATABASE_MODE_READ_WRITE);
-       if (notmuch == NULL)
+       if (notmuch_database_open (db_path, NOTMUCH_DATABASE_MODE_READ_WRITE,
+                                  &notmuch))
            return 1;
 
        if (notmuch_database_needs_upgrade (notmuch)) {
@@ -1038,7 +1041,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
        fprintf (stderr, "Note: A fatal error was encountered: %s\n",
                 notmuch_status_to_string (ret));
 
-    notmuch_database_close (notmuch);
+    notmuch_database_destroy (notmuch);
 
     if (run_hooks && !ret && !interrupted)
        ret = notmuch_run_hook (db_path, "post-new");