From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id +LDtNgodA2DFLgAA0tVLHw (envelope-from ) for ; Sat, 16 Jan 2021 17:06:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SkXhMgodA2DpQQAA1q6Kng (envelope-from ) for ; Sat, 16 Jan 2021 17:06:18 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4922A940509 for ; Sat, 16 Jan 2021 17:06:18 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id E87042BF91; Sat, 16 Jan 2021 12:05:04 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7DBE02BF59 for ; Sat, 16 Jan 2021 12:04:35 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 74FA45FF47; Sat, 16 Jan 2021 12:04:35 -0500 (EST) Received: (nullmailer pid 842408 invoked by uid 1000); Sat, 16 Jan 2021 17:04:15 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 15/38] CLI/restore: convert to new config framework Date: Sat, 16 Jan 2021 13:03:43 -0400 Message-Id: <20210116170406.842014-16-david@tethera.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116170406.842014-1-david@tethera.net> References: <20210116170406.842014-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: XIFTQ7FTBR3A6MXT7O63JRFEMX2U3WHO X-Message-ID-Hash: XIFTQ7FTBR3A6MXT7O63JRFEMX2U3WHO X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.87 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 4922A940509 X-Spam-Score: -0.87 X-Migadu-Scanner: scn1.migadu.com X-TUID: 9t7VRUlYxzoy Switch one configuration check to new n_c_get_bool function, and switch use of config as talloc context to notmuch. --- notmuch-restore.c | 17 ++++++++++------- notmuch.c | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/notmuch-restore.c b/notmuch-restore.c index 544f4228..ce07f89d 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -219,9 +219,8 @@ parse_sup_line (void *ctx, char *line, } int -notmuch_restore_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[]) +notmuch_restore_command (unused(notmuch_config_t *config), notmuch_database_t *notmuch, int argc, char *argv[]) { - notmuch_database_t *notmuch; bool accumulate = false; tag_op_flag_t flags = 0; tag_op_list_t *tag_ops; @@ -238,12 +237,16 @@ notmuch_restore_command (notmuch_config_t *config, unused(notmuch_database_t *no int include = 0; int input_format = DUMP_FORMAT_AUTO; int errnum; + notmuch_bool_t synchronize_flags; - if (notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) + if (print_status_database ( + "notmuch restore", + notmuch, + notmuch_config_get_bool (notmuch, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS, + &synchronize_flags))) return EXIT_FAILURE; - if (notmuch_config_get_maildir_synchronize_flags (config)) + if (synchronize_flags) flags |= TAG_FLAG_MAILDIR_SYNC; notmuch_opt_desc_t options[] = { @@ -310,7 +313,7 @@ notmuch_restore_command (notmuch_config_t *config, unused(notmuch_database_t *no goto DONE; } - tag_ops = tag_op_list_create (config); + tag_ops = tag_op_list_create (notmuch); if (tag_ops == NULL) { fprintf (stderr, "Out of memory.\n"); ret = EXIT_FAILURE; @@ -377,7 +380,7 @@ notmuch_restore_command (notmuch_config_t *config, unused(notmuch_database_t *no if (line_ctx != NULL) talloc_free (line_ctx); - line_ctx = talloc_new (config); + line_ctx = talloc_new (notmuch); if ((include & DUMP_INCLUDE_PROPERTIES) && line_len >= 2 && line[0] == '#' && line[1] == '=') { ret = process_properties_line (notmuch, line + 2); diff --git a/notmuch.c b/notmuch.c index b10cc702..4258ed43 100644 --- a/notmuch.c +++ b/notmuch.c @@ -161,7 +161,7 @@ static command_t commands[] = { "Add/remove tags for all messages matching the search terms." }, { "dump", notmuch_dump_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE, "Create a plain-text dump of the tags for each message." }, - { "restore", notmuch_restore_command, NOTMUCH_COMMAND_CONFIG_OPEN, + { "restore", notmuch_restore_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE, "Restore the tags from the given dump file (see 'dump')." }, { "compact", notmuch_compact_command, NOTMUCH_COMMAND_CONFIG_OPEN, "Compact the notmuch database." }, -- 2.29.2