[PATCH] Skip dot files in `notmuch new`

Tomi Ollila tomi.ollila at nixu.com
Tue Aug 23 23:30:24 PDT 2011


On Wed 24 Aug 2011 03:11, James Vasile <james at hackervisions.org> writes:

> No known mail client or fetch tool stores mail in dot files, because
> files that start with '.' are usually used to store metadata
> (i.e. state or configuration) as opposed to subject-matter data.
>
> Some mail fetch tools (including mbsync) and clients use dot files in
> maildirs to store metadata.  Notmuch should not warn that it is
> ignoring these files, since it *should* ignore them.  Indeed, it
> should ignore all dot files.
> ---
>  notmuch-new.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/notmuch-new.c b/notmuch-new.c
> index 7d17793..87ee07e 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -428,6 +428,10 @@ add_files_recursive (notmuch_database_t *notmuch,
>  	    continue;
>  	}
>  
> +	/* Don't add dot files. */
> +	if (entry->d_name[0] == '.')
> +	    continue;
> +
>  	/* We're now looking at a regular file that doesn't yet exist
>  	 * in the database, so add it. */
>  	next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
> -- 
> 1.7.5.4

yesterday, when I was checking code for something else I was thinking
the same issue: Instead of the above the code sections:

        /* XXX: Eventually we'll want more sophistication to let the
         * user specify files to be ignored. */
        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)
        {
            continue;
        }

and
        /* XXX: Eventually we'll want more sophistication to let the
         * user specify files to be ignored. */
        if (strcmp (entry->d_name, ".") == 0 ||
            strcmp (entry->d_name, "..") == 0 ||
            strcmp (entry->d_name, ".notmuch") == 0)
        {
            continue;
        }

Could be simplified to check just starting dot (.) (and tmp
in add_files_recursive() in case of is_maildir). Maybe
the count_files() function (the latter one above) should
also do the same check so that the numbers count_files()
and add_files() are (almost the) same, causing less confusion
to the user.

I personally don't want to *exclude* more -- I was planning
to hack in code that only include a list of directories under
top level 'db_path'. 


Tomi


More information about the notmuch mailing list