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++;
add_files_state->removed_messages++;
}
notmuch_message_destroy (message);
+
+ DONE:
notmuch_database_end_atomic (notmuch);
return status;
}
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, ¬much))
+ 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,
+ ¬much))
return 1;
if (notmuch_database_needs_upgrade (notmuch)) {
printf ("\n");
if (ret)
- printf ("\nNote: A fatal error was encountered: %s\n",
- notmuch_status_to_string (ret));
+ 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");