unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [BUG] notmuch excludes .notmuch anywhere in the tree
@ 2014-02-23  2:16 Rob Browning
  2014-02-23 19:18 ` [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories Tomi Ollila
  2022-01-24 13:39 ` [BUG] notmuch excludes .notmuch anywhere in the tree David Bremner
  0 siblings, 2 replies; 6+ messages in thread
From: Rob Browning @ 2014-02-23  2:16 UTC (permalink / raw)
  To: notmuch


This might or might not be considered a bug, or at least it might just
be wishlist severity, but in my case, I have

  path=/home/rlb/notmuch

and notmuch contained:

  /home/rlb/notmuch/.notmuch
  /home/rlb/notmuch/Maildir -> /home/Maildir

I arranged things like that so I could easily drop other mail-ish trees
into notmuch/ if I liked, and also so that I wouldn't have to worry
about the fact that maildir++ is going to name the directory for the
notmuch list's folder ".notmuch".  However, I outsmarted myself because
notmuch ignored both "[path]/.notmuch", and "[path]/Maildir/.notmuch".

Though this isn't a critical problem for me.  For now, I just rewrote my
procmail rules and renamed the directory to .notmuchmail.

Hope this helps
-- 
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4

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

* [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories
  2014-02-23  2:16 [BUG] notmuch excludes .notmuch anywhere in the tree Rob Browning
@ 2014-02-23 19:18 ` Tomi Ollila
  2014-02-23 22:22   ` Jani Nikula
  2022-01-24 13:39 ` [BUG] notmuch excludes .notmuch anywhere in the tree David Bremner
  1 sibling, 1 reply; 6+ messages in thread
From: Tomi Ollila @ 2014-02-23 19:18 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

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

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

* Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories
  2014-02-23 19:18 ` [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories Tomi Ollila
@ 2014-02-23 22:22   ` Jani Nikula
  2014-03-01  9:59     ` Mark Walters
  0 siblings, 1 reply; 6+ messages in thread
From: Jani Nikula @ 2014-02-23 22:22 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

On Sun, 23 Feb 2014, Tomi Ollila <tomi.ollila@iki.fi> 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

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

* Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories
  2014-02-23 22:22   ` Jani Nikula
@ 2014-03-01  9:59     ` Mark Walters
  2014-03-01 16:22       ` Rob Browning
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Walters @ 2014-03-01  9:59 UTC (permalink / raw)
  To: Jani Nikula, Tomi Ollila, notmuch; +Cc: tomi.ollila


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 <jani@nikula.org> wrote:
> On Sun, 23 Feb 2014, Tomi Ollila <tomi.ollila@iki.fi> 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

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

* Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories
  2014-03-01  9:59     ` Mark Walters
@ 2014-03-01 16:22       ` Rob Browning
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Browning @ 2014-03-01 16:22 UTC (permalink / raw)
  To: Mark Walters, Jani Nikula, Tomi Ollila, notmuch; +Cc: tomi.ollila

Mark Walters <markwalters1009@gmail.com> writes:

> 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. 

If you wanted to be fairly careful, perhaps test for
exists(".notmuch/.xapian/flintlock" or ".notmuch/.xapian/iamchert"), or
some other very specific test.

> I think the above was suggested by rlb on irc but I don't think it got
> any reply. 

Not sure.  Though I'm wondering if I may have suggested we could add a
notmuch specific token file, i.e. .notmuch/this-really-is-a-notmuch-dir,
which lead to someone else suggesting we could just use .xapian.

Of course broadly speaking, ".xapian" might be a legitimate maildir too,
but ".notmuch/.xapian" seems fairly unlikely.

In any case, while I might prefer a very narrow test (as long as it
wasn't unduly expensive), all of the proposed solutions would have
handled my situation.

Thanks
-- 
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4

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

* Re: [BUG] notmuch excludes .notmuch anywhere in the tree
  2014-02-23  2:16 [BUG] notmuch excludes .notmuch anywhere in the tree Rob Browning
  2014-02-23 19:18 ` [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories Tomi Ollila
@ 2022-01-24 13:39 ` David Bremner
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2022-01-24 13:39 UTC (permalink / raw)
  To: Rob Browning, notmuch

Rob Browning <rlb@defaultvalue.org> writes:

> This might or might not be considered a bug, or at least it might just
> be wishlist severity, but in my case, I have
>
>   path=/home/rlb/notmuch
>
> and notmuch contained:
>
>   /home/rlb/notmuch/.notmuch
>   /home/rlb/notmuch/Maildir -> /home/Maildir
>
> I arranged things like that so I could easily drop other mail-ish trees
> into notmuch/ if I liked, and also so that I wouldn't have to worry
> about the fact that maildir++ is going to name the directory for the
> notmuch list's folder ".notmuch".  However, I outsmarted myself because
> notmuch ignored both "[path]/.notmuch", and "[path]/Maildir/.notmuch".

This should be fixed as of 6472dbf4b7fdec3bd59d7622ef477a035e34c67a

d

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

end of thread, other threads:[~2022-01-24 13:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-23  2:16 [BUG] notmuch excludes .notmuch anywhere in the tree Rob Browning
2014-02-23 19:18 ` [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel directories Tomi Ollila
2014-02-23 22:22   ` Jani Nikula
2014-03-01  9:59     ` Mark Walters
2014-03-01 16:22       ` Rob Browning
2022-01-24 13:39 ` [BUG] notmuch excludes .notmuch anywhere in the tree 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).