X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;ds=sidebyside;f=notmuch-new.c;h=c6a741fefa0361d85cc244638954e9ebb07d2cb5;hb=f8e9d29533250af5f575d63fae4f2f60b4e0bad6;hp=3a60f7cae47fee568d8002f5db178b6ea7587d7a;hpb=85c830405886207196aedbd0a2b757b227ba769d;p=notmuch diff --git a/notmuch-new.c b/notmuch-new.c index 3a60f7ca..c6a741fe 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -261,16 +261,22 @@ add_file (notmuch_database_t *notmuch, const char *filename, if (status) goto DONE; - status = notmuch_database_add_message (notmuch, filename, &message); + status = notmuch_database_index_file (notmuch, filename, NULL, &message); switch (status) { /* Success. */ case NOTMUCH_STATUS_SUCCESS: state->added_messages++; notmuch_message_freeze (message); - for (tag = state->new_tags; *tag != NULL; tag++) - notmuch_message_add_tag (message, *tag); if (state->synchronize_flags) notmuch_message_maildir_flags_to_tags (message); + + for (tag = state->new_tags; *tag != NULL; tag++) { + if (strcmp ("unread", *tag) !=0 || + !notmuch_message_has_maildir_flag (message, 'S')) { + notmuch_message_add_tag (message, *tag); + } + } + notmuch_message_thaw (message); break; /* Non-fatal issues (go on to next file). */ @@ -291,8 +297,7 @@ add_file (notmuch_database_t *notmuch, const char *filename, case NOTMUCH_STATUS_READ_ONLY_DATABASE: case NOTMUCH_STATUS_XAPIAN_EXCEPTION: case NOTMUCH_STATUS_OUT_OF_MEMORY: - fprintf (stderr, "Error: %s. Halting processing.\n", - notmuch_status_to_string (status)); + (void) print_status_database("add_file", notmuch, status); goto DONE; default: INTERNAL_ERROR ("add_message returned unexpected value: %d", status); @@ -438,10 +443,7 @@ add_files (notmuch_database_t *notmuch, /* Pass 1: Recurse into all sub-directories. */ is_maildir = _entries_resemble_maildir (path, fs_entries, num_fs_entries); - for (i = 0; i < num_fs_entries; i++) { - if (interrupted) - break; - + for (i = 0; i < num_fs_entries && ! interrupted; i++) { entry = fs_entries[i]; /* Ignore any files/directories the user has configured to @@ -509,11 +511,7 @@ add_files (notmuch_database_t *notmuch, } /* Pass 2: Scan for new files, removed files, and removed directories. */ - for (i = 0; i < num_fs_entries; i++) - { - if (interrupted) - break; - + for (i = 0; i < num_fs_entries && ! interrupted; i++) { entry = fs_entries[i]; /* Ignore files & directories user has configured to be ignored */