aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-02-02 07:51:23 -0400
committerDavid Bremner <david@tethera.net>2021-03-20 07:50:06 -0300
commitb30a59157d5ba0421c01fa3dc05d238d18738839 (patch)
tree464383b5c40202a9aac11bb0be17d8d5061028ce /lib
parent74c3cc03c219f1046d2672ef686c91b3a7f8b806 (diff)
lib/compact: enable split config
This promotes _choose_xapian_path from static to extern linkage in order to share between open.cc and database.cc.
Diffstat (limited to 'lib')
-rw-r--r--lib/database.cc13
-rw-r--r--lib/notmuch-private.h5
-rw-r--r--lib/open.cc9
3 files changed, 14 insertions, 13 deletions
diff --git a/lib/database.cc b/lib/database.cc
index 248d1dc2..9743c1ca 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -610,11 +610,12 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
void *closure)
{
void *local;
- char *notmuch_path, *xapian_path, *compact_xapian_path;
+ const char *xapian_path, *compact_xapian_path;
const char *path;
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
struct stat statbuf;
bool keep_backup;
+ char *message;
ret = _notmuch_database_ensure_writable (notmuch);
if (ret)
@@ -628,15 +629,9 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
if (! local)
return NOTMUCH_STATUS_OUT_OF_MEMORY;
- if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {
- ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
- goto DONE;
- }
-
- if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) {
- ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
+ ret = _notmuch_choose_xapian_path (local, path, &xapian_path, &message);
+ if (ret)
goto DONE;
- }
if (! (compact_xapian_path = talloc_asprintf (local, "%s.compact", xapian_path))) {
ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index ef814378..387f0c1e 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -724,6 +724,11 @@ _notmuch_config_load_defaults (notmuch_database_t *db);
void
_notmuch_config_cache (notmuch_database_t *db, notmuch_config_key_t key, const char *val);
+/* open.cc */
+notmuch_status_t
+_notmuch_choose_xapian_path (void *ctx, const char *database_path, const char **xapian_path,
+ char **message);
+
NOTMUCH_END_DECLS
#ifdef __cplusplus
diff --git a/lib/open.cc b/lib/open.cc
index 25691a8a..886c1c90 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -258,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;
@@ -489,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;