From: Austin Clements Date: Sun, 25 Nov 2012 05:25:45 +0000 (+1900) Subject: [PATCH 2/2] new: Skip ignored broken symlinks X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=bb673838683982b53e0bf60170e8e346f617085a;p=notmuch-archives.git [PATCH 2/2] new: Skip ignored broken symlinks --- diff --git a/7a/f61361a2ee49ef66cd3c81df7e0845ebb8b367 b/7a/f61361a2ee49ef66cd3c81df7e0845ebb8b367 new file mode 100644 index 000000000..723fabb51 --- /dev/null +++ b/7a/f61361a2ee49ef66cd3c81df7e0845ebb8b367 @@ -0,0 +1,160 @@ +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 4C1D5431FAE + for ; Sat, 24 Nov 2012 21:26:02 -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 3qIDL1EweV0t for ; + Sat, 24 Nov 2012 21:26:00 -0800 (PST) +Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU + [18.7.68.35]) + by olra.theworths.org (Postfix) with ESMTP id AF362431FC0 + for ; Sat, 24 Nov 2012 21:26:00 -0800 (PST) +X-AuditID: 12074423-b7fab6d0000008f9-06-50b1abe7d713 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP + id 85.6F.02297.7EBA1B05; Sun, 25 Nov 2012 00:25:59 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qAP5PnRF014562; + Sun, 25 Nov 2012 00:25:49 -0500 +Received: from drake.dyndns.org + (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [209.6.116.242]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAP5PliO002625 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sun, 25 Nov 2012 00:25:48 -0500 (EST) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1TcUix-0007dW-EQ; Sun, 25 Nov 2012 00:25:47 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 2/2] new: Skip ignored broken symlinks +Date: Sun, 25 Nov 2012 00:25:45 -0500 +Message-Id: <1353821145-29182-3-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1353821145-29182-1-git-send-email-amdragon@mit.edu> +References: <1353821145-29182-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6nrvt89cYAg0n9qhbXb85kdmD0eLbq + FnMAYxSXTUpqTmZZapG+XQJXxr4Vh1gK3shUrD+ymqmB8ZZ4FyMnh4SAicTXt6fZIGwxiQv3 + 1gPZXBxCAvsYJW5PPsUO4WxglJj54gwjhPOISWLdi21QmbmMEu+7/zGB9LMJaEhs27+cEcQW + EZCW2Hl3NmsXIwcHs4CaxJ8uFZCwsICZxN11fcwgNouAqsSp1mNgNq+Ag8TVDfeZIM5QlOh+ + NoENpJVTwFGiebowSFgIqGTvtCWMExj5FzAyrGKUTcmt0s1NzMwpTk3WLU5OzMtLLdI108vN + LNFLTSndxAgOGhflHYx/DiodYhTgYFTi4b2RuDFAiDWxrLgy9xCjJAeTkiiv1jKgEF9Sfkpl + RmJxRnxRaU5q8SFGCQ5mJRFea1WgHG9KYmVValE+TEqag0VJnPdayk1/IYH0xJLU7NTUgtQi + mKwMB4eSBK8KMDqEBItS01Mr0jJzShDSTBycIMN5gIaD1fAWFyTmFmemQ+RPMSpKifNygyQE + QBIZpXlwvbCofsUoDvSKMC8fSBUPMCHAdb8CGswENPjp7HUgg0sSEVJSDYwyT+btnrdaIStO + saRR88AVsZM5n31e7BF89+oly4/OZz5PtaesVLATt1DzCm6pXXd0Qr6rp0F0b2vNQp9/Dnlc + 29K2J/zrS622zHkWvlayVy7tWfYcd1nlmXemeBw0DNuwZXbL571TNHsEppXs3/5wf9y1j+Ls + U76eKTgjuKjJpIKDy/MBe6kSS3FGoqEWc1FxIgCm1/kMxQIAAA== +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, 25 Nov 2012 05:26:02 -0000 + +We now test for user ignore patterns before attempting to determine if +a directory entry is itself a directory. As a result, we no longer +abort for broken symlinks if the user has explicitly ignored them. + +This fixes the test added in the previous patch. It also slightly +changes the debug output checked by another test of ignores. +--- + notmuch-new.c | 26 +++++++++++++++----------- + test/new | 6 +++++- + 2 files changed, 20 insertions(+), 12 deletions(-) + +diff --git a/notmuch-new.c b/notmuch-new.c +index 56c4a6f..718a538 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -350,6 +350,18 @@ add_files (notmuch_database_t *notmuch, + + entry = fs_entries[i]; + ++ /* Ignore any files/directories the user has configured to ++ * ignore. We do this before dirent_type both for performance ++ * and because we don't care if dirent_type fails on entries ++ * that are explicitly ignored. ++ */ ++ if (_entry_in_ignore_list (entry->d_name, state)) { ++ if (state->debug) ++ printf ("(D) add_files_recursive, pass 1: explicitly ignoring %s/%s\n", ++ path, entry->d_name); ++ continue; ++ } ++ + /* We only want to descend into directories (and symlinks to + * directories). */ + entry_type = dirent_type (path, entry); +@@ -364,22 +376,14 @@ add_files (notmuch_database_t *notmuch, + } + + /* Ignore special directories to avoid infinite recursion. +- * Also ignore the .notmuch directory, any "tmp" directory +- * that appears within a maildir and files/directories +- * the user has configured to be ignored. ++ * Also ignore the .notmuch directory and any "tmp" directory ++ * that appears within a maildir. + */ + 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 || +- _entry_in_ignore_list (entry->d_name, state)) +- { +- if (_entry_in_ignore_list (entry->d_name, state) && state->debug) +- printf ("(D) add_files_recursive, pass 1: explicitly ignoring %s/%s\n", +- path, +- entry->d_name); ++ strcmp (entry->d_name, ".notmuch") == 0) + continue; +- } + + next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); + status = add_files (notmuch, next, state); +diff --git a/test/new b/test/new +index 59892a7..8a76e34 100755 +--- a/test/new ++++ b/test/new +@@ -192,7 +192,12 @@ touch "${MAIL_DIR}"/{one,one/two,one/two/three}/ignored_file + output=$(NOTMUCH_NEW --debug 2>&1 | sort) + test_expect_equal "$output" \ + "(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/.git ++(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file ++(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/ignored_file ++(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/ignored_file ++(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/ignored_file + (D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/three/.git ++(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/three/ignored_file + (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/.git + (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file + (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/ignored_file +@@ -204,7 +209,6 @@ No new mail." + + + test_begin_subtest "Don't stop for ignored broken symlinks" +-test_subtest_known_broken + notmuch config set new.ignore .git ignored_file .ignored_hidden_file broken_link + ln -s i_do_not_exist "${MAIL_DIR}"/broken_link + output=$(NOTMUCH_NEW 2>&1) +-- +1.7.10.4 +