mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
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.
This commit is contained in:
parent
74c3cc03c2
commit
b30a59157d
4 changed files with 21 additions and 13 deletions
|
@ -610,11 +610,12 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
|
||||||
void *closure)
|
void *closure)
|
||||||
{
|
{
|
||||||
void *local;
|
void *local;
|
||||||
char *notmuch_path, *xapian_path, *compact_xapian_path;
|
const char *xapian_path, *compact_xapian_path;
|
||||||
const char *path;
|
const char *path;
|
||||||
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
|
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
bool keep_backup;
|
bool keep_backup;
|
||||||
|
char *message;
|
||||||
|
|
||||||
ret = _notmuch_database_ensure_writable (notmuch);
|
ret = _notmuch_database_ensure_writable (notmuch);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -628,15 +629,9 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
|
||||||
if (! local)
|
if (! local)
|
||||||
return NOTMUCH_STATUS_OUT_OF_MEMORY;
|
return NOTMUCH_STATUS_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {
|
ret = _notmuch_choose_xapian_path (local, path, &xapian_path, &message);
|
||||||
ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
if (ret)
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
|
||||||
|
|
||||||
if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) {
|
|
||||||
ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
|
||||||
goto DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! (compact_xapian_path = talloc_asprintf (local, "%s.compact", xapian_path))) {
|
if (! (compact_xapian_path = talloc_asprintf (local, "%s.compact", xapian_path))) {
|
||||||
ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -724,6 +724,11 @@ _notmuch_config_load_defaults (notmuch_database_t *db);
|
||||||
void
|
void
|
||||||
_notmuch_config_cache (notmuch_database_t *db, notmuch_config_key_t key, const char *val);
|
_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
|
NOTMUCH_END_DECLS
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -258,9 +258,9 @@ _trial_open (const char *xapian_path, char **message_ptr)
|
||||||
return NOTMUCH_STATUS_SUCCESS;
|
return NOTMUCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static notmuch_status_t
|
notmuch_status_t
|
||||||
_choose_xapian_path (void *ctx, const char *database_path, const char **xapian_path,
|
_notmuch_choose_xapian_path (void *ctx, const char *database_path,
|
||||||
char **message_ptr)
|
const char **xapian_path, char **message_ptr)
|
||||||
{
|
{
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
const char *trial_path, *notmuch_path;
|
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);
|
_set_database_path (notmuch, database_path);
|
||||||
|
|
||||||
status = _choose_xapian_path (notmuch, database_path, ¬much->xapian_path, &message);
|
status = _notmuch_choose_xapian_path (notmuch, database_path,
|
||||||
|
¬much->xapian_path, &message);
|
||||||
if (status)
|
if (status)
|
||||||
goto DONE;
|
goto DONE;
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,13 @@ EOF
|
||||||
cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
|
cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
|
||||||
test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
|
test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
|
||||||
|
|
||||||
|
|
||||||
|
test_begin_subtest "compact+search ($config)"
|
||||||
|
notmuch search --output=messages '*' | sort > EXPECTED
|
||||||
|
notmuch compact
|
||||||
|
notmuch search --output=messages '*' | sort > OUTPUT
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
restore_config
|
restore_config
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue