From: Jani Nikula Date: Sun, 23 Feb 2014 22:22:10 +0000 (+0200) Subject: Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3e2c60c9f795de04b6032fa29e24980f1fcfd66d;p=notmuch-archives.git Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories --- diff --git a/b6/7fe1d6e78e6d8922260bbe225fd055e2c1e1de b/b6/7fe1d6e78e6d8922260bbe225fd055e2c1e1de new file mode 100644 index 000000000..35f227b7d --- /dev/null +++ b/b6/7fe1d6e78e6d8922260bbe225fd055e2c1e1de @@ -0,0 +1,196 @@ +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 816D2431FD6 + for ; Sun, 23 Feb 2014 14:22:24 -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 3wycUm3baTpm for ; + Sun, 23 Feb 2014 14:22:15 -0800 (PST) +Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com + [74.125.83.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 2196E431FCF for ; Sun, 23 Feb 2014 14:22:15 -0800 + (PST) +Received: by mail-ee0-f51.google.com with SMTP id b57so2772311eek.24 + for ; Sun, 23 Feb 2014 14:22:12 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=bOHTjL7f0i3cgmPvbIjdEDHqj6hW7DLI9abvLBhb0os=; + b=h702OTZN6zGQ/o0ntFKjPdr8KDeFOY1K3PpABWW6l7gest/6MTk3cfOy8bIqeDpK7H + P/STHExxG9vQ4ammz6P1R0qKVRKSzcfChrCo8k06lj6FfxFF/N0FvSLhi4zeM//CV+mZ + aApT6Rvktm4eyzK7Fur7ESY0cqfl1JxYBMSUn5WZjeDj/dyvvuuedGEmoNbkPHvUwbeL + 4zyzoEr3j5fPDnUewQbI3wdH7Vusu2ySGn8fQn/l6S26RhIPPbjCN2Vjij0kb4P3lFn4 + o6rpIs09dBAsJ3+AYQcJJE53mmV1CBgyU/nPBNr/8anVLN5IqySajy1c+P5f9IgKwsh7 + fpcw== +X-Gm-Message-State: + ALoCoQmf+YlgnuVpSV81WyilYP/jaDsNAHwst/bRkrZ8TIQ3z/T8Kl8S5Z+l7H7eBxKDNWWo3bJX +X-Received: by 10.14.221.201 with SMTP id r49mr21126016eep.104.1393194132605; + Sun, 23 Feb 2014 14:22:12 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) + by mx.google.com with ESMTPSA id q44sm56081208eez.1.2014.02.23.14.22.11 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 23 Feb 2014 14:22:11 -0800 (PST) +From: Jani Nikula +To: Tomi Ollila , notmuch@notmuchmail.org +Subject: Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in + non-toplevel directories +In-Reply-To: <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi> +References: <87mwhifu9a.fsf@trouble.defaultvalue.org> + <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi> +User-Agent: Notmuch/0.17+44~ge3b4cd9 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Mon, 24 Feb 2014 00:22:10 +0200 +Message-ID: <87ios5v59p.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +Cc: tomi.ollila@iki.fi +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: Sun, 23 Feb 2014 22:22:24 -0000 + +On Sun, 23 Feb 2014, Tomi Ollila wrote: +> So that users may have email in subdir/.notmuch directories. +> --- +> +> Compiles, current tests pass. might ignore database_path/.notmuch and +> might descent into database_path/.../.notmuch :D +> +> Tomi +> +> +> notmuch-new.c | 18 ++++++++++-------- +> 1 file changed, 10 insertions(+), 8 deletions(-) +> +> diff --git a/notmuch-new.c b/notmuch-new.c +> index 8529fdd..b17bd75 100644 +> --- a/notmuch-new.c +> +++ b/notmuch-new.c +> @@ -344,7 +344,8 @@ add_file (notmuch_database_t *notmuch, const char *filename, +> static notmuch_status_t +> add_files (notmuch_database_t *notmuch, +> const char *path, +> - add_files_state_t *state) +> + add_files_state_t *state, +> + int dirlevel) + +I think this is ugly and makes the interface harder to use for indexing +arbitrary paths. + +Instead, I suggest + +diff --git a/notmuch-new.c b/notmuch-new.c +index 8529fdd3eac7..20bc33fca4bd 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -469,7 +469,8 @@ add_files (notmuch_database_t *notmuch, + if (strcmp (entry->d_name, ".") == 0 || + strcmp (entry->d_name, "..") == 0 || + (is_maildir && strcmp (entry->d_name, "tmp") == 0) || +- strcmp (entry->d_name, ".notmuch") == 0) ++ (strcmp (entry->d_name, ".notmuch") == 0 && ++ strcmp (path, notmuch_database_get_path (notmuch)) == 0)) + continue; + + next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); + +And similarly in count_files(), with the root db path passed as first +argument (as the db is not open yet). + + +BR, +Jani. + + + +> { +> DIR *dir = NULL; +> struct dirent *entry = NULL; +> @@ -469,11 +470,11 @@ add_files (notmuch_database_t *notmuch, +> if (strcmp (entry->d_name, ".") == 0 || +> strcmp (entry->d_name, "..") == 0 || +> (is_maildir && strcmp (entry->d_name, "tmp") == 0) || +> - strcmp (entry->d_name, ".notmuch") == 0) +> + (dirlevel == 0 && strcmp (entry->d_name, ".notmuch") == 0)) +> continue; +> +> next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); +> - status = add_files (notmuch, next, state); +> + status = add_files (notmuch, next, state, dirlevel + 1); +> if (status) { +> ret = status; +> goto DONE; +> @@ -702,7 +703,8 @@ stop_progress_printing_timer (void) +> * initialized to zero by the top-level caller before calling +> * count_files). */ +> static void +> -count_files (const char *path, int *count, add_files_state_t *state) +> +count_files (const char *path, int *count, add_files_state_t *state, +> + int dirlevel) +> { +> struct dirent *entry = NULL; +> char *next; +> @@ -725,7 +727,7 @@ count_files (const char *path, int *count, add_files_state_t *state) +> */ +> if (strcmp (entry->d_name, ".") == 0 || +> strcmp (entry->d_name, "..") == 0 || +> - strcmp (entry->d_name, ".notmuch") == 0 || +> + (dirlevel == 0 && strcmp (entry->d_name, ".notmuch") == 0) || +> _entry_in_ignore_list (entry->d_name, state)) +> { +> if (state->debug && _entry_in_ignore_list (entry->d_name, state)) +> @@ -750,7 +752,7 @@ count_files (const char *path, int *count, add_files_state_t *state) +> fflush (stdout); +> } +> } else if (entry_type == S_IFDIR) { +> - count_files (next, count, state); +> + count_files (next, count, state, dirlevel + 1); +> } +> +> free (next); +> @@ -962,7 +964,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> int count; +> +> count = 0; +> - count_files (db_path, &count, &add_files_state); +> + count_files (db_path, &count, &add_files_state, 0); +> if (interrupted) +> return EXIT_FAILURE; +> +> @@ -1021,7 +1023,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) +> timer_is_active = TRUE; +> } +> +> - ret = add_files (notmuch, db_path, &add_files_state); +> + ret = add_files (notmuch, db_path, &add_files_state, 0); +> if (ret) +> goto DONE; +> +> -- +> 1.8.4.2 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch