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 iHpLAozS818gCgAA0tVLHw (envelope-from ) for ; Tue, 05 Jan 2021 02:44:28 +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 zYWkOYvS81/hYwAA1q6Kng (envelope-from ) for ; Tue, 05 Jan 2021 02:44:27 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 6F0D09403A2 for ; Tue, 5 Jan 2021 02:44:26 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id E1C2728535; Mon, 4 Jan 2021 21:44:13 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id BAA4827C7D for ; Mon, 4 Jan 2021 21:44:09 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 14F8560666; Mon, 4 Jan 2021 21:24:11 -0500 (EST) Received: (nullmailer pid 644503 invoked by uid 1000); Tue, 05 Jan 2021 02:24:06 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 3/5] lib/open: move path calculations after notmuch object creation Date: Mon, 4 Jan 2021 22:23:48 -0400 Message-Id: <20210105022350.643917-4-david@tethera.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210105022350.643917-1-david@tethera.net> References: <20210105022350.643917-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: Q3BFJPXYOXQBMRQ4YRZCC63PJGZBJUL2 X-Message-ID-Hash: Q3BFJPXYOXQBMRQ4YRZCC63PJGZBJUL2 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.44 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 6F0D09403A2 X-Spam-Score: 0.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: 0Pza6Dr0rdTT This is just code movement. A future commit will need the notmuch object to exist for the path manipulation. --- lib/open.cc | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index 12cbbbd0..ede367af 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -169,26 +169,6 @@ notmuch_database_open_with_config (const char *database_path, if ((status = _pre_open (config_path, profile, &key_file, &database_path, &message))) goto DONE; - if (! (notmuch_path = talloc_asprintf (local, "%s/%s", database_path, ".notmuch"))) { - message = strdup ("Out of memory\n"); - status = NOTMUCH_STATUS_OUT_OF_MEMORY; - goto DONE; - } - - err = stat (notmuch_path, &st); - if (err) { - IGNORE_RESULT (asprintf (&message, "Error opening database at %s: %s\n", - notmuch_path, strerror (errno))); - status = NOTMUCH_STATUS_FILE_ERROR; - goto DONE; - } - - if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) { - message = strdup ("Out of memory\n"); - status = NOTMUCH_STATUS_OUT_OF_MEMORY; - goto DONE; - } - /* Initialize the GLib type system and threads */ #if ! GLIB_CHECK_VERSION (2, 35, 1) g_type_init (); @@ -210,6 +190,27 @@ notmuch_database_open_with_config (const char *database_path, notmuch->writable_xapian_db = NULL; notmuch->atomic_nesting = 0; notmuch->view = 1; + + if (! (notmuch_path = talloc_asprintf (local, "%s/%s", database_path, ".notmuch"))) { + message = strdup ("Out of memory\n"); + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } + + err = stat (notmuch_path, &st); + if (err) { + IGNORE_RESULT (asprintf (&message, "Error opening database at %s: %s\n", + notmuch_path, strerror (errno))); + status = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } + + if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) { + message = strdup ("Out of memory\n"); + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } + try { std::string last_thread_id; std::string last_mod; -- 2.29.2