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 CA11E431FBF for ; Sat, 1 Mar 2014 02:00:14 -0800 (PST) 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 OeoWUdyuwoQD for ; Sat, 1 Mar 2014 02:00:07 -0800 (PST) Received: from mail1.qmul.ac.uk (mail1.qmul.ac.uk [138.37.6.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 17C75431FAF for ; Sat, 1 Mar 2014 02:00:07 -0800 (PST) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail1.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1WJghy-0001FF-GD; Sat, 01 Mar 2014 09:59:54 +0000 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) (envelope-from ) id 1WJghy-0000Pz-5N; Sat, 01 Mar 2014 09:59:50 +0000 From: Mark Walters To: Jani Nikula , Tomi Ollila , notmuch@notmuchmail.org Subject: Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories In-Reply-To: <87ios5v59p.fsf@nikula.org> References: <87mwhifu9a.fsf@trouble.defaultvalue.org> <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi> <87ios5v59p.fsf@nikula.org> User-Agent: Notmuch/0.15.2+562~g339f306 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Sat, 01 Mar 2014 09:59:49 +0000 Message-ID: <87r46mgrxm.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 93.97.24.31 X-QM-Geographic: According to ripencc, this message was delivered by a machine in Britain (UK) (GB). X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 1d30acd25db47e7da29da32f9c3df73d (of first 20000 bytes) X-SpamAssassin-Score: 0.0 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 0.0 points. Summary of the scoring: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * 0.0 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Sat, 01 Mar 2014 10:00:15 -0000 An alternative would be to ignore any .notmuch path with a xapian sub-directory. This would mean if a user indexed some subset of their mail before trying to index the whole thing they wouldn't accidentally index the old xapian database. Alternatively we could just view the above as user error. (If a user wanted to have an index for a sub-directory they would have to use excludes to exclude that index from the full-directory index). Best wishes Mark I think the above was suggested by rlb on irc but I don't think it got any reply. On Sun, 23 Feb 2014, Jani Nikula wrote: > 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 > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch