]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-dump.c
cli: convert remainder of CLI to n_q_search_{messages,threads}_st
[notmuch] / notmuch-dump.c
index 2849eabaadb9b292b0eab8e4dab6c10d4b26398d..829781f8b44feba2f76fb4e39427c5f1029b7fd1 100644 (file)
@@ -48,8 +48,13 @@ database_dump_file (notmuch_database_t *notmuch, gzFile output,
 
     char *buffer = NULL;
     size_t buffer_size = 0;
+    notmuch_status_t status;
 
-    for (messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch dump", query, status))
+       return EXIT_FAILURE;
+
+    for (;
         notmuch_messages_valid (messages);
         notmuch_messages_move_to_next (messages)) {
        int first = 1;
@@ -169,7 +174,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
     }
 
     if (output_file_name) {
-       ret = fdatasync (outfd);
+       ret = fsync (outfd);
        if (ret) {
            fprintf (stderr, "Error syncing %s to disk: %s\n",
                     name_for_error, strerror (errno));
@@ -212,9 +217,11 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
     int ret;
 
     if (notmuch_database_open (notmuch_config_get_database_path (config),
-                              NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))
+                              NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))
        return EXIT_FAILURE;
 
+    notmuch_exit_if_unmatched_db_uuid (notmuch);
+
     char *output_file_name = NULL;
     int opt_index;
 
@@ -228,6 +235,7 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
                                  { 0, 0 } } },
        { NOTMUCH_OPT_STRING, &output_file_name, "output", 'o', 0  },
        { NOTMUCH_OPT_BOOLEAN, &gzip_output, "gzip", 'z', 0 },
+       { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },
        { 0, 0, 0, 0, 0 }
     };
 
@@ -235,6 +243,8 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
     if (opt_index < 0)
        return EXIT_FAILURE;
 
+    notmuch_process_shared_options (argv[0]);
+
     if (opt_index < argc) {
        query_str = query_string_from_args (notmuch, argc - opt_index, argv + opt_index);
        if (query_str == NULL) {