[PATCH 19/22] lib/compact: enable split config

2021-03-14 Thread David Bremner
This promotes _choose_xapian_path from static to extern linkage in
order to share between open.cc and database.cc.
---
 lib/database.cc  | 13 -
 lib/notmuch-private.h|  5 +
 lib/open.cc  |  9 +
 test/T055-path-config.sh |  7 +++
 4 files changed, 21 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, _path, );
+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 3097121e..8321a3be 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 (local, database_path, >xapian_path, 
);
+status = _notmuch_choose_xapian_path (local, database_path,
+ >xapian_path, );
 if (status)
goto DONE;
 
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index fb5174ac..e4812c82 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -177,6 +177,13 @@ EOF
 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
 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
 done
 
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 19/22] lib/compact: enable split config

2021-03-07 Thread David Bremner
This promotes _choose_xapian_path from static to extern linkage in
order to share between open.cc and database.cc.
---
 lib/database.cc  | 13 -
 lib/notmuch-private.h|  4 
 lib/open.cc  |  7 ---
 test/T055-path-config.sh |  7 +++
 4 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 12ab1af7..491ede5e 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -609,11 +609,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)
@@ -627,15 +628,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, _path, );
+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 1174c43c..05443d20 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -724,6 +724,10 @@ _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 95c93744..08f2f052 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -258,8 +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;
@@ -486,7 +487,7 @@ notmuch_database_open_with_config (const char 
*database_path,
 
 _set_database_path (notmuch, database_path);
 
-status = _choose_xapian_path (local, database_path, >xapian_path, 
);
+status = _notmuch_choose_xapian_path (local, database_path, 
>xapian_path, );
 if (status)
goto DONE;
 
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index fb5174ac..e4812c82 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -177,6 +177,13 @@ EOF
 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
 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
 done
 
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 19/22] lib/compact: enable split config

2021-03-04 Thread David Bremner
This promotes _choose_xapian_path from static to extern linkage in
order to share between open.cc and database.cc.
---
 lib/database.cc  | 13 -
 lib/notmuch-private.h|  4 
 lib/open.cc  |  6 +++---
 test/T055-path-config.sh |  7 +++
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 1d8839a5..ffd42ac4 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -607,11 +607,12 @@ notmuch_database_compact_db (notmuch_database_t *notmuch,
 notmuch_compact_status_cb_t status_cb,
 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)
@@ -625,15 +626,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, _path, );
+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 2808bbb3..b884f060 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -724,6 +724,10 @@ _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 a21f6252..1e2a62cd 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -250,8 +250,8 @@ _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;
 
@@ -474,7 +474,7 @@ notmuch_database_open_with_config (const char 
*database_path,
 
 _set_database_path (notmuch, database_path);
 
-status = _choose_xapian_path (local, database_path, >xapian_path, 
);
+status = _notmuch_choose_xapian_path (local, database_path, 
>xapian_path, );
 if (status)
goto DONE;
 
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index fb5174ac..e4812c82 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -177,6 +177,13 @@ EOF
 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
 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
 done
 
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org