]> git.notmuchmail.org Git - notmuch/commitdiff
lib/open: use _finish_open in n_d_create_with_config
authorDavid Bremner <david@tethera.net>
Sat, 30 Jan 2021 17:30:18 +0000 (13:30 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 20 Mar 2021 10:33:25 +0000 (07:33 -0300)
This avoids reading the configuration file twice.

lib/open.cc

index cc099e51123eb5b5a37e3f4322dfc2d012122e04..09afd29493dbbd25b0d88f3b75cd3f94cc41ddba 100644 (file)
@@ -550,12 +550,16 @@ notmuch_database_create_with_config (const char *database_path,
        goto DONE;
     }
 
-    /* XXX this reads the config file twice, which is a bit wasteful */
-    status = notmuch_database_open_with_config (database_path,
-                                               NOTMUCH_DATABASE_MODE_READ_WRITE,
-                                               config_path,
-                                               profile,
-                                               &notmuch, &message);
+    if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) {
+       status = NOTMUCH_STATUS_OUT_OF_MEMORY;
+       goto DONE;
+    }
+
+    status = _finish_open (notmuch,
+                          profile,
+                          NOTMUCH_DATABASE_MODE_READ_WRITE,
+                          key_file,
+                          &message);
     if (status)
        goto DONE;