Re: [RFC PATCH 10/14] new: add "scan" option
authorMark Walters <markwalters1009@gmail.com>
Thu, 28 Jun 2012 20:54:32 +0000 (21:54 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:52 +0000 (09:47 -0800)
7e/c598c9d790f009ea26a603208ee2617b04342d [new file with mode: 0644]

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