X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch-new.c;h=e6c283eb7ca123b762f0db4fa69cb33cb17d3e31;hb=2e9ecb611a7f698808add756b2ddcbdfcd8b7c8b;hp=d269c7cd7e254badd4ae85ca026a478a8cad4655;hpb=a7eaa4d84a909275fe0c089f8dbf346ebcdc69c6;p=notmuch diff --git a/notmuch-new.c b/notmuch-new.c index d269c7cd..e6c283eb 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -923,6 +923,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_bool_t timer_is_active = FALSE; notmuch_bool_t no_hooks = FALSE; notmuch_bool_t quiet = FALSE, verbose = FALSE; + notmuch_status_t status; add_files_state.verbosity = VERBOSITY_NORMAL; add_files_state.debug = FALSE; @@ -984,9 +985,16 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) return EXIT_FAILURE; add_files_state.total_files = count; } else { - if (notmuch_database_open (db_path, NOTMUCH_DATABASE_MODE_READ_WRITE, - ¬much)) + char *status_string = NULL; + if (notmuch_database_open_verbose (db_path, NOTMUCH_DATABASE_MODE_READ_WRITE, + ¬much, &status_string)) { + if (status_string) { + fputs (status_string, stderr); + free (status_string); + } + return EXIT_FAILURE; + } if (notmuch_database_needs_upgrade (notmuch)) { time_t now = time (NULL); @@ -1019,12 +1027,18 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) } gettimeofday (&add_files_state.tv_start, NULL); - notmuch_database_upgrade (notmuch, - add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL, - &add_files_state); + status = notmuch_database_upgrade ( + notmuch, + add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL, + &add_files_state); + if (status) { + printf ("Upgrade failed: %s\n", + notmuch_status_to_string (status)); + notmuch_database_destroy (notmuch); + return EXIT_FAILURE; + } if (add_files_state.verbosity >= VERBOSITY_NORMAL) - printf ("Your notmuch database has now been upgraded to database format version %u.\n", - notmuch_database_get_version (notmuch)); + printf ("Your notmuch database has now been upgraded.\n"); } add_files_state.total_files = 0; @@ -1091,7 +1105,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) } for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) { - notmuch_status_t status; notmuch_directory_t *directory; status = notmuch_database_get_directory (notmuch, f->filename, &directory); if (status == NOTMUCH_STATUS_SUCCESS && directory) {