]> git.cworth.org Git - notmuch/commitdiff
cli/compact: convert to new configuration framework
authorDavid Bremner <david@tethera.net>
Thu, 24 Dec 2020 03:45:23 +0000 (23:45 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 6 Feb 2021 23:36:06 +0000 (19:36 -0400)
Switch to the newly created API function notmuch_database_compact_db,
which takes the database opened in main().

notmuch-compact.c
notmuch.c
test/T035-read-config.sh

index ab2066e1ddc5032f270b5944992a5d9fc974eff1..361583db878b1ba4863db1b1f8720bb6175152e5 100644 (file)
@@ -27,9 +27,8 @@ status_update_cb (const char *msg, unused (void *closure))
 }
 
 int
-notmuch_compact_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[])
+notmuch_compact_command (unused(notmuch_config_t *config), notmuch_database_t *notmuch, int argc, char *argv[])
 {
-    const char *path = notmuch_config_get_database_path (config);
     const char *backup_path = NULL;
     notmuch_status_t ret;
     bool quiet = false;
@@ -55,8 +54,8 @@ notmuch_compact_command (notmuch_config_t *config, unused(notmuch_database_t *no
 
     if (! quiet)
        printf ("Compacting database...\n");
-    ret = notmuch_database_compact (path, backup_path,
-                                   quiet ? NULL : status_update_cb, NULL);
+    ret = notmuch_database_compact_db (notmuch, backup_path,
+                                      quiet ? NULL : status_update_cb, NULL);
     if (ret) {
        fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string (ret));
        return EXIT_FAILURE;
index 913fd312c58be76e64472dbac2de93a58d5a9a42..3a299afa0079d7996a388833907f1c63809e388a 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -163,7 +163,7 @@ static command_t commands[] = {
       "Create a plain-text dump of the tags for each message." },
     { "restore", notmuch_restore_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE,
       "Restore the tags from the given dump file (see 'dump')." },
-    { "compact", notmuch_compact_command, NOTMUCH_COMMAND_CONFIG_OPEN,
+    { "compact", notmuch_compact_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE,
       "Compact the notmuch database." },
     { "reindex", notmuch_reindex_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE,
       "Re-index all messages matching the search terms." },
index 6dc7ccbbacd9fb0ddddb8884f888991600aac0f7..102aea60e86aa6c4ef3d19cce409547696e61b8d 100755 (executable)
@@ -447,4 +447,18 @@ EOF
 restore_config
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "running compact (xdg)"
+xdg_config
+notmuch compact
+output=$(notmuch count '*')
+restore_config
+test_expect_equal "52" "$output"
+
+test_begin_subtest "running compact (xdg + profile)"
+xdg_config ${RANDOM}
+notmuch compact
+output=$(notmuch count '*')
+restore_config
+test_expect_equal "52" "$output"
+
 test_done