summaryrefslogtreecommitdiffstats
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-02-06 18:50:20 -0400
committerDavid Bremner <david@tethera.net>2021-03-19 22:06:19 -0300
commit6e6c319c260b779e6e91905f8c142ad2b82a41c9 (patch)
tree78752d1ed860263a616bf1fd446297ab07060c3d /notmuch-show.c
parenta9f74aeeb9ade477d5b80c1c2700945d6c50adb1 (diff)
CLI/show: complete conversion to new configuration framework.
In order to open the database in main() for this command, we may need to re-open it in the (possibly less common) case where crypto options require write access.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index b6b53991..481e5d54 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1225,10 +1225,9 @@ static const notmuch_show_format_t *formatters[] = {
};
int
-notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch),
+notmuch_show_command (unused (notmuch_config_t *config), notmuch_database_t *notmuch,
int argc, char *argv[])
{
- notmuch_database_t *notmuch;
notmuch_query_t *query;
char *query_string;
int opt_index, ret;
@@ -1245,7 +1244,7 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu
bool entire_thread_set = false;
bool single_message;
bool unthreaded = FALSE;
- char *status_string = NULL;
+ notmuch_status_t status;
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords =
@@ -1336,26 +1335,15 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu
"Warning: --include-html only implemented for format=text, format=json and format=sexp\n");
}
- notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
-
- if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE)
- mode = NOTMUCH_DATABASE_MODE_READ_WRITE;
- if (notmuch_database_open_with_config (NULL,
- mode,
- _notmuch_config_get_path (config),
- NULL,
- &notmuch,
- &status_string)) {
- if (status_string) {
- fputs (status_string, stderr);
- free (status_string);
+ if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) {
+ status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_WRITE);
+ if (status) {
+ fprintf (stderr, "Error reopening database for READ_WRITE: %s\n",
+ notmuch_status_to_string (status));
+ return EXIT_FAILURE;
}
-
- return EXIT_FAILURE;
}
- config = NULL;
-
notmuch_exit_if_unmatched_db_uuid (notmuch);
query_string = query_string_from_args (notmuch, argc - opt_index, argv + opt_index);