Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 77D11431E64 for ; Mon, 22 Sep 2014 02:55:47 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6ZhzrI+MIBb7 for ; Mon, 22 Sep 2014 02:55:42 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E08AA431FB6 for ; Mon, 22 Sep 2014 02:55:03 -0700 (PDT) Received: by mail-wi0-f178.google.com with SMTP id z2so2595047wiv.17 for ; Mon, 22 Sep 2014 02:55:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=PBJQxHSoX9KA16B5+BILW0xYv/wo2GniPJ2bC1fie3E=; b=OG7lLkpFaelii1+5V3dnr1Eztt+xPnFaeuGH0TLevUN6ZakOAIcXg5SdBC3fDaRL7u B/n5Is2o9EETQnXp71uZC/HDyHoLfd1M3s4+pKGK+gCMtgUL3DWTzIZGVuzTKqe65E57 48Pe7WxobnKu71xQtoou3DXBlECWgXeatChqDA2T6COOWtgjG3k35O1wLgIhVgQWCV8W PdqTnWnhANfafwgy/8xleXe8u6pwAZrDVJIvdcvOENIBxS2BtMgd+Fq5PDDaA5+h6Kdf qvYoaK73hrtoksvEFDsMjfBOfiqpf/CgV9LRnFelhgDABz+P2GAULJz+w8zaZOKG9pdk tqIg== X-Gm-Message-State: ALoCoQmEffzZ+vvEaj58uiSQjuGWf4MYUVedCNAfbQQKtpZe78xE1qImA452OHG5u3LGQlzeqEHE X-Received: by 10.194.24.101 with SMTP id t5mr19093082wjf.76.1411379702760; Mon, 22 Sep 2014 02:55:02 -0700 (PDT) Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) by mx.google.com with ESMTPSA id fo6sm11499896wic.3.2014.09.22.02.55.02 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 22 Sep 2014 02:55:02 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH 11/11] cli/insert: add post-insert hook Date: Mon, 22 Sep 2014 11:55:02 +0200 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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, 22 Sep 2014 09:55:47 -0000 The post-new hook might no longer be needed or run very often if notmuch insert is being used. Therefore a post-insert hook is needed (arguably pre-insert not so much, so don't add one). Also add the --no-hooks option to skip hooks. --- notmuch-insert.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/notmuch-insert.c b/notmuch-insert.c index f27b9cb..adadd12 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -444,6 +444,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) const char *folder = NULL; notmuch_bool_t create_folder = FALSE; notmuch_bool_t keep = FALSE; + notmuch_bool_t no_hooks = FALSE; notmuch_bool_t synchronize_flags; const char *maildir; char *newpath; @@ -454,6 +455,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 }, { NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 }, { NOTMUCH_OPT_BOOLEAN, &keep, "keep", 0, 0 }, + { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 }, { NOTMUCH_OPT_END, 0, 0, 0, 0 } }; @@ -541,5 +543,10 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_database_destroy (notmuch); + if (! no_hooks && status == NOTMUCH_STATUS_SUCCESS) { + /* Ignore hook failures. */ + notmuch_run_hook (db_path, "post-insert"); + } + return status ? EXIT_FAILURE : EXIT_SUCCESS; } -- 1.7.2.5