[PATCH v2 4/8] new: add "scan" option
authorEthan Glasser-Camp <ethan.glasser.camp@gmail.com>
Sun, 1 Jul 2012 16:39:46 +0000 (12:39 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:55 +0000 (09:47 -0800)
09/00162e30644bddc641272a895b95d343bb76be [new file with mode: 0644]

diff --git a/09/00162e30644bddc641272a895b95d343bb76be b/09/00162e30644bddc641272a895b95d343bb76be
new file mode 100644 (file)
index 0000000..6fa0a3e
--- /dev/null
@@ -0,0 +1,239 @@
+Return-Path: <ethan.glasser.camp@gmail.com>\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 B8913431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 09:46:07 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.061\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.061 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.246,\r
+       RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=0.614] 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 gB2xCOqmtyvR for <notmuch@notmuchmail.org>;\r
+       Sun,  1 Jul 2012 09:46:07 -0700 (PDT)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ BBD09431FAF   for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 09:46:06 -0700\r
+ (PDT)\r
+Received: by wgbdt14 with SMTP id dt14so3720895wgb.2\r
+       for <notmuch@notmuchmail.org>; Sun, 01 Jul 2012 09:46:05 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=YHzkxLnuVlTBuioDrrEwI0x6FOi3UmhIQIDC0yQ+AB8=;\r
+       b=uMXdbO7bTW2qk5jMSTzBvoPoKvlULSNIH7C4kNd0Pnkd+bamxi0j/0qolEeT1FQ/cV\r
+       haym2FOwjfBjYfZQ1AY+dZz3zr0S/UGQgP2MeZeyFpQnCKtHu9+tvONy/9GSGgC8vIWo\r
+       9kXeeEDNvFZy7R2MPB3GFhIPyv28X0zzbEY2/kJyns/jqRCuLPKbMnE5afGuL2+YyLRc\r
+       M4M3QQKYv8fl4AMNZ4v/m7eOzm+UDHGiIvNHNvhYIYOHQy29WH9K3EwMPK6ZsvlzvgnR\r
+       HMrVpNLBzjMWlMynDEmMsKRQQnBtbd7AJ6Bg27NCwqUdecCWGOviYR3TMqzYgTa72aeJ\r
+       0pEg==\r
+Received: by 10.216.226.32 with SMTP id a32mr439540weq.190.1341161165346;\r
+       Sun, 01 Jul 2012 09:46:05 -0700 (PDT)\r
+Received: from localhost ([195.24.209.21])\r
+       by mx.google.com with ESMTPS id fw4sm19720264wib.0.2012.07.01.09.45.48\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 01 Jul 2012 09:46:04 -0700 (PDT)\r
+From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 4/8] new: add "scan" option\r
+Date: Sun,  1 Jul 2012 12:39:46 -0400\r
+Message-Id: <1341160790-14525-5-git-send-email-ethan@betacantrips.com>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <1341160790-14525-1-git-send-email-ethan@betacantrips.com>\r
+References:\r
+ <CAOJ+Ob0MSOez2MvD2fCgF7t32kFPk4g2+xCud88QmBLt_b5pOA@mail.gmail.com>\r
+       <1341160790-14525-1-git-send-email-ethan@betacantrips.com>\r
+Cc: Ethan Glasser-Camp <ethan@betacantrips.com>\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: Sun, 01 Jul 2012 16:46:07 -0000\r
+\r
+The new.scan option is a list of URLs that can be "scanned".\r
+\r
+The fact that the database 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
+Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+---\r
+I added text here to respond to Mark Walters's confusion regarding how\r
+I implemented scanning.\r
+\r
+ notmuch-client.h |    9 +++++++++\r
+ notmuch-config.c |   33 ++++++++++++++++++++++++++++++++-\r
+ notmuch-new.c    |   18 ++++++++++++++++++\r
+ test/config      |    1 +\r
+ 4 files changed, 60 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 0c17b79..20349b2 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -257,6 +257,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..387f855 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -50,7 +50,13 @@ 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       Each URL denotes a \"root\" which will be searched for mail files.\n"\r
++    "\t       How this search is performed depends on the scheme of the URL (the\n"\r
++    "\t       part before the first colon).\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 +119,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 +282,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 +385,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 +645,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 +680,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 938ae29..8377750 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -607,6 +607,16 @@ add_files (notmuch_database_t *notmuch,\r
+     return ret;\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
+ static void\r
+ setup_progress_printing_timer (void)\r
+ {\r
+@@ -832,6 +842,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
+@@ -930,6 +942,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