From: Mark Walters Date: Thu, 28 Jun 2012 20:54:32 +0000 (+0100) Subject: Re: [RFC PATCH 10/14] new: add "scan" option X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=7242809c425ed2a3e9cc1fcc41bca88d875aaa69;p=notmuch-archives.git Re: [RFC PATCH 10/14] new: add "scan" option --- diff --git a/7e/c598c9d790f009ea26a603208ee2617b04342d b/7e/c598c9d790f009ea26a603208ee2617b04342d new file mode 100644 index 000000000..63cdf40b6 --- /dev/null +++ b/7e/c598c9d790f009ea26a603208ee2617b04342d @@ -0,0 +1,265 @@ +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 2BC3A431FB6 + for ; Thu, 28 Jun 2012 13:54:46 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 utag0Xkjg23S for ; + Thu, 28 Jun 2012 13:54:45 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id ED721431FAF + for ; Thu, 28 Jun 2012 13:54:44 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1SkLjb-0002eN-Cj; Thu, 28 Jun 2012 21:54:43 +0100 +Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] + helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1SkLja-00051P-RH; Thu, 28 Jun 2012 21:54:39 +0100 +From: Mark Walters +To: Ethan Glasser-Camp , notmuch@notmuchmail.org +Subject: Re: [RFC PATCH 10/14] new: add "scan" option +In-Reply-To: <1340657517-6539-6-git-send-email-ethan@betacantrips.com> +References: <1340657517-6539-1-git-send-email-ethan@betacantrips.com> + <1340657517-6539-6-git-send-email-ethan@betacantrips.com> +User-Agent: Notmuch/0.13.2+63~g548a9bf (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Thu, 28 Jun 2012 21:54:32 +0100 +Message-ID: <87ehozma2f.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.192.233.223 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 7856a2c025354e887455a3bf3ae18751 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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, 28 Jun 2012 20:54:46 -0000 + +On Mon, 25 Jun 2012, Ethan Glasser-Camp wrote: +> This is just a quick hack to get started on adding an mbox backend. +> +> The fact that the default maildir is scanned "automagically" is a +> little weird, but it doesn't do any harm unless you decide to put mail +> there that you really don't want indexed. + +I was a bit caught out by the way this worked. I expected that I would +add +scan=mbox:///full_path_of_mbox +but instead it seems that I need to add +scan=mbox:///full_path_of_directory_containing_the_mbox + +I am happy with either (and yours is probably easier) but it should be +documented somewhere and I found the line +> + "\tscan A list (separated by ';') of mail URLs to scan.\n" + +confusing. + +Best wishes + +Mark + +> Signed-off-by: Ethan Glasser-Camp +> --- +> notmuch-client.h | 9 +++++++++ +> notmuch-config.c | 30 +++++++++++++++++++++++++++++- +> notmuch-new.c | 18 ++++++++++++++++++ +> test/config | 1 + +> 4 files changed, 57 insertions(+), 1 deletion(-) +> +> diff --git a/notmuch-client.h b/notmuch-client.h +> index 9b63eae..9d922fe 100644 +> --- a/notmuch-client.h +> +++ b/notmuch-client.h +> @@ -256,6 +256,15 @@ notmuch_config_set_new_ignore (notmuch_config_t *config, +> const char *new_ignore[], +> size_t length); +> +> +const char ** +> +notmuch_config_get_new_scan (notmuch_config_t *config, +> + size_t *length); +> + +> +void +> +notmuch_config_set_new_scan (notmuch_config_t *config, +> + const char *new_scan[], +> + size_t length); +> + +> notmuch_bool_t +> notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config); +> +> diff --git a/notmuch-config.c b/notmuch-config.c +> index 3e37a2d..e9d99ea 100644 +> --- a/notmuch-config.c +> +++ b/notmuch-config.c +> @@ -50,7 +50,10 @@ static const char new_config_comment[] = +> "\t that will not be searched for messages by \"notmuch new\".\n" +> "\n" +> "\t NOTE: *Every* file/directory that goes by one of those names will\n" +> - "\t be ignored, independent of its depth/location in the mail store.\n"; +> + "\t be ignored, independent of its depth/location in the mail store.\n" +> + "\n" +> + "\tscan A list (separated by ';') of mail URLs to scan.\n" +> + "\t The maildir located at database.path, above, will automatically be added.\n"; +> +> static const char user_config_comment[] = +> " User configuration\n" +> @@ -113,6 +116,8 @@ struct _notmuch_config { +> size_t new_tags_length; +> const char **new_ignore; +> size_t new_ignore_length; +> + const char **new_scan; +> + size_t new_scan_length; +> notmuch_bool_t maildir_synchronize_flags; +> const char **search_exclude_tags; +> size_t search_exclude_tags_length; +> @@ -274,6 +279,8 @@ notmuch_config_open (void *ctx, +> config->new_tags_length = 0; +> config->new_ignore = NULL; +> config->new_ignore_length = 0; +> + config->new_scan = NULL; +> + config->new_scan_length = 0; +> config->maildir_synchronize_flags = TRUE; +> config->search_exclude_tags = NULL; +> config->search_exclude_tags_length = 0; +> @@ -375,6 +382,10 @@ notmuch_config_open (void *ctx, +> notmuch_config_set_new_ignore (config, NULL, 0); +> } +> +> + if (notmuch_config_get_new_scan (config, &tmp) == NULL) { +> + notmuch_config_set_new_scan (config, NULL, 0); +> + } +> + +> if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) { +> if (is_new) { +> const char *tags[] = { "deleted", "spam" }; +> @@ -631,6 +642,14 @@ notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length) +> &(config->new_ignore_length), length); +> } +> +> +const char ** +> +notmuch_config_get_new_scan (notmuch_config_t *config, size_t *length) +> +{ +> + return _config_get_list (config, "new", "scan", +> + &(config->new_scan), +> + &(config->new_scan_length), length); +> +} +> + +> void +> notmuch_config_set_user_other_email (notmuch_config_t *config, +> const char *list[], +> @@ -658,6 +677,15 @@ notmuch_config_set_new_ignore (notmuch_config_t *config, +> &(config->new_ignore)); +> } +> +> +void +> +notmuch_config_set_new_scan (notmuch_config_t *config, +> + const char *list[], +> + size_t length) +> +{ +> + _config_set_list (config, "new", "scan", list, length, +> + &(config->new_scan)); +> +} +> + +> const char ** +> notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length) +> { +> diff --git a/notmuch-new.c b/notmuch-new.c +> index 1f11b2c..57b27bf 100644 +> --- a/notmuch-new.c +> +++ b/notmuch-new.c +> @@ -239,6 +239,16 @@ _entry_in_ignore_list (const char *entry, add_files_state_t *state) +> return FALSE; +> } +> +> +/* Call out to the appropriate add_files function, based on the URI. */ +> +static notmuch_status_t +> +add_files_uri (unused(notmuch_database_t *notmuch), +> + unused(const char *uri), +> + unused(add_files_state_t *state)) +> +{ +> + /* Stub for now */ +> + return NOTMUCH_STATUS_SUCCESS; +> +} +> + +> /* Examine 'path' recursively as follows: +> * +> * o Ask the filesystem for the mtime of 'path' (fs_mtime) +> @@ -843,6 +853,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) +> int ret = 0; +> struct stat st; +> const char *db_path; +> + const char **new_scan; +> + size_t new_scan_length, new_scan_i; +> char *dot_notmuch_path; +> struct sigaction action; +> _filename_node_t *f; +> @@ -941,6 +953,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) +> timer_is_active = TRUE; +> } +> +> + new_scan = notmuch_config_get_new_scan (config, &new_scan_length); +> + +> + for (new_scan_i = 0; new_scan_i < new_scan_length; new_scan_i++) { +> + add_files_uri (notmuch, new_scan[new_scan_i], &add_files_state); +> + } +> + +> ret = add_files (notmuch, db_path, &add_files_state); +> if (ret) +> goto DONE; +> diff --git a/test/config b/test/config +> index 93ecb13..b0ad0c1 100755 +> --- a/test/config +> +++ b/test/config +> @@ -52,6 +52,7 @@ user.primary_email=test_suite@notmuchmail.org +> user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org +> new.tags=unread;inbox; +> new.ignore= +> +new.scan= +> search.exclude_tags= +> maildir.synchronize_flags=true +> foo.string=this is another string value +> -- +> 1.7.9.5 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch