X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-new.c;h=33645349cd5fd8abdb5936e185b5f5c70d529c08;hp=569100560accbc393a52b124d14f55178fb6e63d;hb=acd66cdec075312944e527febd46382e54d99367;hpb=26b6470db350cc4b319934c1caff261ada12b4bb diff --git a/notmuch-new.c b/notmuch-new.c index 56910056..33645349 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -528,6 +528,10 @@ add_files (notmuch_database_t *notmuch, "%s/%s", path, notmuch_filenames_get (db_files)); + if (state->debug) + printf ("(D) add_files_recursive, pass 2: queuing passed file %s for deletion from database\n", + absolute); + _filename_list_add (state->removed_files, absolute); notmuch_filenames_move_to_next (db_files); @@ -542,6 +546,9 @@ add_files (notmuch_database_t *notmuch, { char *absolute = talloc_asprintf (state->removed_directories, "%s/%s", path, filename); + if (state->debug) + printf ("(D) add_files_recursive, pass 2: queuing passed directory %s for deletion from database\n", + absolute); _filename_list_add (state->removed_directories, absolute); } @@ -610,6 +617,9 @@ add_files (notmuch_database_t *notmuch, char *absolute = talloc_asprintf (state->removed_files, "%s/%s", path, notmuch_filenames_get (db_files)); + if (state->debug) + printf ("(D) add_files_recursive, pass 3: queuing leftover file %s for deletion from database\n", + absolute); _filename_list_add (state->removed_files, absolute); @@ -622,6 +632,10 @@ add_files (notmuch_database_t *notmuch, "%s/%s", path, notmuch_filenames_get (db_subdirs)); + if (state->debug) + printf ("(D) add_files_recursive, pass 3: queuing leftover directory %s for deletion from database\n", + absolute); + _filename_list_add (state->removed_directories, absolute); notmuch_filenames_move_to_next (db_subdirs); @@ -662,7 +676,7 @@ setup_progress_printing_timer (void) struct sigaction action; struct itimerval timerval; - /* Setup our handler for SIGALRM */ + /* Set up our handler for SIGALRM */ memset (&action, 0, sizeof (struct sigaction)); action.sa_handler = handle_sigalrm; sigemptyset (&action.sa_mask); @@ -864,6 +878,15 @@ _remove_directory (void *ctx, goto DONE; } + /* + * XXX: The library does not have a function to remove a directory + * document for a path. Usually this doesn't matter except for a + * slight waste of space. However, if the directory gets added to + * the filesystem again, the old directory document is found with + * the old mtime. Reset the directory mtime to avoid problems. + */ + notmuch_directory_set_mtime (directory, 0); + DONE: notmuch_directory_destroy (directory); return status; @@ -934,6 +957,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 }, { NOTMUCH_OPT_BOOLEAN, &add_files_state.debug, "debug", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -941,6 +965,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; + notmuch_process_shared_options (argv[0]); + /* quiet trumps verbose */ if (quiet) add_files_state.verbosity = VERBOSITY_QUIET; @@ -985,9 +1011,17 @@ 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; + } + + notmuch_exit_if_unmatched_db_uuid (notmuch); if (notmuch_database_needs_upgrade (notmuch)) { time_t now = time (NULL); @@ -1031,8 +1065,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) 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; @@ -1041,7 +1074,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) if (notmuch == NULL) return EXIT_FAILURE; - /* Setup our handler for SIGINT. We do this after having + /* Set up our handler for SIGINT. We do this after having * potentially done a database upgrade we this interrupt handler * won't support. */ memset (&action, 0, sizeof (struct sigaction));