X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-new.c;h=33645349cd5fd8abdb5936e185b5f5c70d529c08;hp=e6c283eb7ca123b762f0db4fa69cb33cb17d3e31;hb=acd66cdec075312944e527febd46382e54d99367;hpb=84d3b15d251623cbb66e5eca7ddb8d61aa596d33 diff --git a/notmuch-new.c b/notmuch-new.c index e6c283eb..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; @@ -992,10 +1018,11 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) 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); struct tm *gm_time = gmtime (&now); @@ -1047,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));