From 76e5e53db1c05a7ef4ff6f263fd6a7e613e5f3cf Mon Sep 17 00:00:00 2001 From: Ethan Glasser-Camp Date: Tue, 26 Jun 2012 16:51:53 +2000 Subject: [PATCH] [RFC PATCH 10/14] new: add "scan" option --- 4a/2f18724e88630f4a7cb5fc6ed0767417839514 | 231 ++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 4a/2f18724e88630f4a7cb5fc6ed0767417839514 diff --git a/4a/2f18724e88630f4a7cb5fc6ed0767417839514 b/4a/2f18724e88630f4a7cb5fc6ed0767417839514 new file mode 100644 index 000000000..9dde9bd7b --- /dev/null +++ b/4a/2f18724e88630f4a7cb5fc6ed0767417839514 @@ -0,0 +1,231 @@ +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 EF2EC431FC2 + for ; Mon, 25 Jun 2012 13:53:49 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 1.061 +X-Spam-Level: * +X-Spam-Status: No, score=1.061 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.246, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=0.614] 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 UD8P465nqgBD for ; + Mon, 25 Jun 2012 13:53:49 -0700 (PDT) +Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com + [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 03C28431FAF for ; Mon, 25 Jun 2012 13:53:48 -0700 + (PDT) +Received: by wgbdt14 with SMTP id dt14so3710368wgb.2 + for ; Mon, 25 Jun 2012 13:53:47 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=FHnNafQToxQ2x10ZyiW9HfN0hgVl0OZ7fBfEXC9nMDQ=; + b=y3OJNmxcyoNOXQLd74YHiYjmfszW8WcMnJa+Y5ottk4XP4XfeLF+3h7xJjqMEctrwr + 0E0JYx5u0I1yPy4zTcLw17gAmkiRtPz5kNCAxPz4ADAOKeA9RhDHIvRPNHkZzzO5EJKx + YK08IMIyULkJrLXou2bxYTV26bAuHh7XP7laWEMVcdJ6PRZX544hV+2n10VhUKJW2xNC + YN9EDlni5K55eWWRFcgyBzpUcTqnNmNPk1YN2rQ45vPzk32vZ2/G10L2o9aZRPp/Lkh4 + E5FOiZAwGUrd4Eo9NuDHTd/VPlAau+hYJYOP2TD+wPrbKHo8WjUc3VmZD8Yu+Dl2GSJG + J2/w== +Received: by 10.180.80.37 with SMTP id o5mr27148754wix.12.1340657627636; + Mon, 25 Jun 2012 13:53:47 -0700 (PDT) +Received: from localhost ([195.24.209.21]) + by mx.google.com with ESMTPS id hs8sm37653wib.10.2012.06.25.13.53.31 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 25 Jun 2012 13:53:35 -0700 (PDT) +From: Ethan Glasser-Camp +To: notmuch@notmuchmail.org +Subject: [RFC PATCH 10/14] new: add "scan" option +Date: Mon, 25 Jun 2012 16:51:53 -0400 +Message-Id: <1340657517-6539-6-git-send-email-ethan@betacantrips.com> +X-Mailer: git-send-email 1.7.9.5 +In-Reply-To: <1340657517-6539-1-git-send-email-ethan@betacantrips.com> +References: <1340657517-6539-1-git-send-email-ethan@betacantrips.com> +X-Mailman-Approved-At: Tue, 26 Jun 2012 03:51:54 -0700 +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, 25 Jun 2012 20:53:50 -0000 + +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. + +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 + -- 2.26.2