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 021F9431FD6 for ; Sun, 23 Feb 2014 11:18:59 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 pPXkDCG6riJQ for ; Sun, 23 Feb 2014 11:18:55 -0800 (PST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 65CDB431FCF for ; Sun, 23 Feb 2014 11:18:55 -0800 (PST) Received: by guru.guru-group.fi (Postfix, from userid 501) id A6987100086; Sun, 23 Feb 2014 21:18:49 +0200 (EET) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories Date: Sun, 23 Feb 2014 21:18:47 +0200 Message-Id: <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 1.8.0 In-Reply-To: <87mwhifu9a.fsf@trouble.defaultvalue.org> References: <87mwhifu9a.fsf@trouble.defaultvalue.org> 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 19:18:59 -0000 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) { 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