unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Ignore ignored broken symlinks
@ 2012-11-25  5:25 Austin Clements
  2012-11-25  5:25 ` [PATCH 1/2] test: Add a test for skipping " Austin Clements
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Austin Clements @ 2012-11-25  5:25 UTC (permalink / raw)
  To: notmuch

calmar on IRC reported a bug today where notmuch will abort when it
encounters a broken symlink, even if that symlink is in the
user-specified ignore list.  These two patches test for this bug and
fix it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] test: Add a test for skipping ignored broken symlinks
  2012-11-25  5:25 [PATCH 0/2] Ignore ignored broken symlinks Austin Clements
@ 2012-11-25  5:25 ` Austin Clements
  2012-11-25  5:25 ` [PATCH 2/2] new: Skip " Austin Clements
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Austin Clements @ 2012-11-25  5:25 UTC (permalink / raw)
  To: notmuch

Currently marked as broken because we abort on broken symlinks, even
if they are in the ignore list.
---
 test/new |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/new b/test/new
index 587aa11..59892a7 100755
--- a/test/new
+++ b/test/new
@@ -203,4 +203,11 @@ test_expect_equal "$output" \
 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)
+test_expect_equal "$output" "No new mail."
+
 test_done
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] new: Skip ignored broken symlinks
  2012-11-25  5:25 [PATCH 0/2] Ignore ignored broken symlinks Austin Clements
  2012-11-25  5:25 ` [PATCH 1/2] test: Add a test for skipping " Austin Clements
@ 2012-11-25  5:25 ` Austin Clements
  2012-11-25 10:19 ` [PATCH 0/2] Ignore " Tomi Ollila
  2012-11-27  2:23 ` David Bremner
  3 siblings, 0 replies; 6+ messages in thread
From: Austin Clements @ 2012-11-25  5:25 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] Ignore ignored broken symlinks
  2012-11-25  5:25 [PATCH 0/2] Ignore ignored broken symlinks Austin Clements
  2012-11-25  5:25 ` [PATCH 1/2] test: Add a test for skipping " Austin Clements
  2012-11-25  5:25 ` [PATCH 2/2] new: Skip " Austin Clements
@ 2012-11-25 10:19 ` Tomi Ollila
  2012-11-25 11:46   ` Mark Walters
  2012-11-27  2:23 ` David Bremner
  3 siblings, 1 reply; 6+ messages in thread
From: Tomi Ollila @ 2012-11-25 10:19 UTC (permalink / raw)
  To: Austin Clements, notmuch

On Sun, Nov 25 2012, Austin Clements <amdragon@MIT.EDU> wrote:

> calmar on IRC reported a bug today where notmuch will abort when it
> encounters a broken symlink, even if that symlink is in the
> user-specified ignore list.  These two patches test for this bug and
> fix it.

+1

Tomi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] Ignore ignored broken symlinks
  2012-11-25 10:19 ` [PATCH 0/2] Ignore " Tomi Ollila
@ 2012-11-25 11:46   ` Mark Walters
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Walters @ 2012-11-25 11:46 UTC (permalink / raw)
  To: Tomi Ollila, Austin Clements, notmuch

On Sun, 25 Nov 2012, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> On Sun, Nov 25 2012, Austin Clements <amdragon@MIT.EDU> wrote:
>
>> calmar on IRC reported a bug today where notmuch will abort when it
>> encounters a broken symlink, even if that symlink is in the
>> user-specified ignore list.  These two patches test for this bug and
>> fix it.
>
> +1


+1 from me too

Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] Ignore ignored broken symlinks
  2012-11-25  5:25 [PATCH 0/2] Ignore ignored broken symlinks Austin Clements
                   ` (2 preceding siblings ...)
  2012-11-25 10:19 ` [PATCH 0/2] Ignore " Tomi Ollila
@ 2012-11-27  2:23 ` David Bremner
  3 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2012-11-27  2:23 UTC (permalink / raw)
  To: Austin Clements, notmuch; +Cc: calmar c.

Austin Clements <amdragon@MIT.EDU> writes:

> calmar on IRC reported a bug today where notmuch will abort when it
> encounters a broken symlink, even if that symlink is in the
> user-specified ignore list.  These two patches test for this bug and
> fix it.
>

I have pushed this to master.

calmar, your symlink bug should be fixed in the latest git master.

d

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-27  2:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-25  5:25 [PATCH 0/2] Ignore ignored broken symlinks Austin Clements
2012-11-25  5:25 ` [PATCH 1/2] test: Add a test for skipping " Austin Clements
2012-11-25  5:25 ` [PATCH 2/2] new: Skip " Austin Clements
2012-11-25 10:19 ` [PATCH 0/2] Ignore " Tomi Ollila
2012-11-25 11:46   ` Mark Walters
2012-11-27  2:23 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).