From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id D98E26DE1204 for ; Mon, 28 Nov 2016 14:12:42 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.006 X-Spam-Level: X-Spam-Status: No, score=-0.006 tagged_above=-999 required=5 tests=[AWL=0.005, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zoqb8uBgWBiH for ; Mon, 28 Nov 2016 14:12:42 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 373276DE115F for ; Mon, 28 Nov 2016 14:12:42 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cBU9s-0000hI-9X; Mon, 28 Nov 2016 17:12:20 -0500 Received: (nullmailer pid 25589 invoked by uid 1000); Mon, 28 Nov 2016 22:12:37 -0000 From: David Bremner To: David Bremner , Maarten Aertsen , Notmuch Mail Subject: [PATCH 2/3] cli/insert: delay database open until after writing mail file Date: Mon, 28 Nov 2016 18:12:30 -0400 Message-Id: <20161128221231.25528-3-david@tethera.net> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161128221231.25528-1-david@tethera.net> References: <20161128121641.4022-2-david@tethera.net> <20161128221231.25528-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2016 22:12:42 -0000 The idea is to get the mail written to disk, even if we can't open the database (e.g. because some other process has a write lock, and notmuch is compiled for non-blocking opens). --- notmuch-insert.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/notmuch-insert.c b/notmuch-insert.c index 131f09e..862da88 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -532,19 +532,19 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) action.sa_flags = 0; sigaction (SIGINT, &action, NULL); - if (notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) - return EXIT_FAILURE; - - notmuch_exit_if_unmatched_db_uuid (notmuch); - /* Write the message to the Maildir new directory. */ newpath = maildir_write_new (config, STDIN_FILENO, maildir); if (! newpath) { - notmuch_database_destroy (notmuch); return EXIT_FAILURE; } + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) + return EXIT_FAILURE; + + notmuch_exit_if_unmatched_db_uuid (notmuch); + + /* Index the message. */ status = add_file (notmuch, newpath, tag_ops, synchronize_flags, keep); -- 2.10.2