]> git.cworth.org Git - notmuch/blobdiff - lib/open.cc
lib/compact: enable split config
[notmuch] / lib / open.cc
index 0dfd295f2e8b8da1166cd0e3184789ccef5d0510..886c1c90bcd89e575596d0cefb4e13d00b6b30a3 100644 (file)
@@ -181,6 +181,7 @@ _choose_database_path (void *ctx,
                       const char *profile,
                       GKeyFile **key_file,
                       const char **database_path,
+                      bool *split,
                       char **message)
 {
     notmuch_status_t status;
@@ -203,6 +204,11 @@ _choose_database_path (void *ctx,
        }
     }
 
+    if (! *database_path) {
+       *database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile);
+       *split = true;
+    }
+
     if (*database_path == NULL) {
        *message = strdup ("Error: Cannot open a database for a NULL path.\n");
        return NOTMUCH_STATUS_NULL_POINTER;
@@ -252,9 +258,9 @@ _trial_open (const char *xapian_path, char **message_ptr)
     return NOTMUCH_STATUS_SUCCESS;
 }
 
-static notmuch_status_t
-_choose_xapian_path (void *ctx, const char *database_path, const char **xapian_path,
-                    char **message_ptr)
+notmuch_status_t
+_notmuch_choose_xapian_path (void *ctx, const char *database_path,
+                            const char **xapian_path, char **message_ptr)
 {
     notmuch_status_t status;
     const char *trial_path, *notmuch_path;
@@ -462,6 +468,7 @@ notmuch_database_open_with_config (const char *database_path,
     notmuch_database_t *notmuch = NULL;
     char *message = NULL;
     GKeyFile *key_file = NULL;
+    bool split = false;
 
     _init_libs ();
 
@@ -471,7 +478,8 @@ notmuch_database_open_with_config (const char *database_path,
        goto DONE;
     }
 
-    if ((status = _choose_database_path (local, config_path, profile, &key_file, &database_path,
+    if ((status = _choose_database_path (local, config_path, profile,
+                                        &key_file, &database_path, &split,
                                         &message)))
        goto DONE;
 
@@ -481,7 +489,8 @@ notmuch_database_open_with_config (const char *database_path,
 
     _set_database_path (notmuch, database_path);
 
-    status = _choose_xapian_path (notmuch, database_path, &notmuch->xapian_path, &message);
+    status = _notmuch_choose_xapian_path (notmuch, database_path,
+                                         &notmuch->xapian_path, &message);
     if (status)
        goto DONE;
 
@@ -563,7 +572,8 @@ notmuch_database_create_with_config (const char *database_path,
     _init_libs ();
 
     if ((status = _choose_database_path (local, config_path, profile,
-                                        &key_file, &database_path, &message)))
+                                        &key_file, &database_path, &split,
+                                        &message)))
        goto DONE;
 
     status = _db_dir_exists (database_path, &message);