From: Austin Clements Date: Thu, 6 Mar 2014 21:06:22 +0000 (+1900) Subject: Re: [PATCH] notmuch new: add a --in-directory option X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6e8f30fff96967461e751ff02e7967000657474b;p=notmuch-archives.git Re: [PATCH] notmuch new: add a --in-directory option --- diff --git a/89/85c94cda83099d98d6b089f5daf3538554c83b b/89/85c94cda83099d98d6b089f5daf3538554c83b new file mode 100644 index 000000000..dc7c8b86a --- /dev/null +++ b/89/85c94cda83099d98d6b089f5daf3538554c83b @@ -0,0 +1,161 @@ +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 01BC6431FAF + for ; Thu, 6 Mar 2014 13:06:33 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +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 91RJWhfdfZhp for ; + Thu, 6 Mar 2014 13:06:27 -0800 (PST) +Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu + [18.7.68.36]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 61B75431FAE + for ; Thu, 6 Mar 2014 13:06:27 -0800 (PST) +X-AuditID: 12074424-f79e26d000000c70-a7-5318e352716d +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id 45.0F.03184.253E8135; Thu, 6 Mar 2014 16:06:26 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s26L6PxD009277; + Thu, 6 Mar 2014 16:06:26 -0500 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s26L6MmV024989 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Thu, 6 Mar 2014 16:06:24 -0500 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1WLfUk-0003PV-Ox; Thu, 06 Mar 2014 16:06:22 -0500 +Date: Thu, 6 Mar 2014 16:06:22 -0500 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH] notmuch new: add a --in-directory option +Message-ID: <20140306210622.GI4709@mit.edu> +References: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT1w16LBFs0P9GyWL1XB6L6zdnMjsw + eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGR/6VjEXfBGvWHp2GlMDY4dwFyMnh4SAicTF + Q+tZIWwxiQv31rN1MXJxCAnMZpLYuO8XK4SzgVHi4PW1TBDOKSaJ/51boDJLGCUOb93ECNLP + IqAisfDoTrBZbAIaEtv2LweLiwjoSNw+tIAdxGYWkJb49ruZCcQWFrCV+P3gM1icV0BbYu31 + XSwgtpCAp8Sxw/eZIOKCEidnPmGB6NWSuPHvJVCcA2zO8n8cIGFOAS+JX49OgpWLAp0w5eQ2 + tgmMQrOQdM9C0j0LoXsBI/MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXXO93MwSvdSU0k2M4LB2 + UdnB2HxI6RCjAAejEg9vxyKJYCHWxLLiytxDjJIcTEqivO4PgEJ8SfkplRmJxRnxRaU5qcWH + GCU4mJVEeI0PAuV4UxIrq1KL8mFS0hwsSuK8fWeBUgLpiSWp2ampBalFMFkZDg4lCV6zR0BZ + waLU9NSKtMycEoQ0EwcnyHAeoOFaIDW8xQWJucWZ6RD5U4yKUuK8viAJAZBERmkeXC8s7bxi + FAd6RZi3DKSKB5iy4LpfAQ1mAhoczScOMrgkESEl1cCY0lcotKg5Z+fqsNRXBgyPlC9Vz3qV + VnCqPethuGipu+ay4uJnzRKpyyaUByT/r5Bt3lH7/+Y22TcJFmclyqZ1Xr69fk4rf1x4QwY3 + a7VYl9feZUZR3U/zFp5O7P32vJmxc9rJVfUH3n9+7Pk3fcrXpUfLt3zZYvb8vV+xgMP1kM+a + z6vZPb8osRRnJBpqMRcVJwIAfC45tRYDAAA= +Cc: notmuch@notmuchmail.org +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: Thu, 06 Mar 2014 21:06:34 -0000 + +I haven't thought about this as a patch yet, but wanted to point out +that it should probably skip the removal step if it's only scanning a +subdirectory. Otherwise, messages that are moved out of the scanned +directory into some other may be considered deleted and get removed +from the database. + +That aside, I'm curious what the use case for this is. + +Quoth Mark Walters on Mar 06 at 8:58 pm: +> This patch adds a --in-directory=folder option to notmuch new which +> tells it to only check for new messages inside folder (relative to the +> database root) +> --- +> +> NOTE This is only very lightly tested (but seems to work) so please +> make sure you backup the notmuch database before testing! +> +> +> notmuch-new.c | 10 +++++++++- +> test/T050-new.sh | 15 +++++++++++++++ +> 2 files changed, 24 insertions(+), 1 deletions(-) +> +> diff --git a/notmuch-new.c b/notmuch-new.c +> index 8529fdd..d3526ac 100644 +> --- a/notmuch-new.c +> +++ b/notmuch-new.c +> @@ -922,6 +922,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> notmuch_bool_t timer_is_active = FALSE; +> notmuch_bool_t no_hooks = FALSE; +> notmuch_bool_t quiet = FALSE, verbose = FALSE; +> + char *directory = NULL; +> + char *path = NULL; +> +> add_files_state.verbosity = VERBOSITY_NORMAL; +> add_files_state.debug = FALSE; +> @@ -932,6 +934,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> { NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 }, +> { NOTMUCH_OPT_BOOLEAN, &add_files_state.debug, "debug", 'd', 0 }, +> { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 }, +> + { NOTMUCH_OPT_STRING, &directory, "in-directory", 'i', 0 }, +> { 0, 0, 0, 0, 0 } +> }; +> +> @@ -1021,7 +1024,12 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> timer_is_active = TRUE; +> } +> +> - ret = add_files (notmuch, db_path, &add_files_state); +> + if (directory) +> + path = talloc_asprintf (config, "%s/%s", db_path, directory); +> + else +> + path = talloc_strdup (config, db_path); +> + +> + ret = add_files (notmuch, path, &add_files_state); +> if (ret) +> goto DONE; +> +> diff --git a/test/T050-new.sh b/test/T050-new.sh +> index b7668ff..b8e68a3 100755 +> --- a/test/T050-new.sh +> +++ b/test/T050-new.sh +> @@ -263,4 +263,19 @@ notmuch search --format=text0 --output=files --offset=1 --limit=1 '*' | xargs -0 +> output=$(NOTMUCH_NEW --quiet) +> test_expect_equal "$output" "" +> +> +test_begin_subtest "In-directory" +> +rm -rf "${MAIL_DIR}"/* "${MAIL_DIR}"/.notmuch +> +mkdir "${MAIL_DIR}"/def +> +mkdir "${MAIL_DIR}"/ghi +> +generate_message [dir]=def +> +generate_message [dir]=ghi +> +generate_message +> + +> +output=$(NOTMUCH_NEW --in-directory=def) +> +test_expect_equal "$output" "Added 1 new message to the database." +> + +> +test_begin_subtest "New after --in-directory" +> +output=$(NOTMUCH_NEW) +> +test_expect_equal "$output" "Added 2 new messages to the database." +> + +> test_done