]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-new.c
CLI/new: support maildir synced tags in new.tags
[notmuch] / notmuch-new.c
index 3a60f7cae47fee568d8002f5db178b6ea7587d7a..e011788da590a74433a526c5fe727e604be7db3e 100644 (file)
@@ -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);