Re: [PATCH] notmuch-mutt: check that the search cache Maildir is not a real Maildir WAS: Re: Data loss

2023-05-27 Thread Paul Wise
On Sat, 2023-05-27 at 21:10 -0300, David Bremner wrote:

> If possible, please use git-send-email for future series. 

Will do, I forgot about the --cover-letter option.

> This seems to have introduced a warning, and I think there's a bug.
> 
> % notmuch mutt search tag:inbox 
> Argument "new" isn't numeric in array or hash lookup at /usr/bin/notmuch-mutt 
> line 70.
> Argument "cur" isn't numeric in array or hash lookup at /usr/bin/notmuch-mutt 
> line 70.
> Argument "tmp" isn't numeric in array or hash lookup at /usr/bin/notmuch-mutt 
> line 70.
> 
> If I remember correctly you need to use {} for hash references in Perl.

Woops! Thanks, fixed in the v2 patch series.

> It might clearer to use the return value from (a possibly renamed
> check_search_cache (then the -d can be eliminated / folded into the new
> function).

When the checks fail, the Maildir creation and Maildir symlink
additions shouldn't happen either, otherwise Maildirs with real data
may get mail files overwritten with symlinks back to themselves. So
there needs to be a die() or return before the creation and the search
anyway and so checks may as well just die() when the first check fails.

I experimented with returning anyway and it makes things more complex:

File::Find cannot abort the search except via die() and so the calling
code would need to use eval in order to catch the die() and return it.

Threading return values all the way back up to search_action adds lots
of error checks to every function along the way.

The search_action interactive mode doesn't do more than one search
anyway so it would still just need to die() when there is an error.

If the code were to grow a multi-command interactive prompt, that could
use eval to catch and print the die() errors. Such a prompt would need
to do that anyway, because the non-search actions call die() already.

So I think that throwing exceptions via die() is the simpler method.

Since checking that the Maildir is suitable is really a separate action
to clearing the previous search results, I've moved the check function
from the empty function to the search function in the v2 patch series.

-- 
bye,
pabs

https://bonedaddy.net/pabs3/


signature.asc
Description: This is a digitally signed message part
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] notmuch-mutt: check that the search cache Maildir is not a real Maildir WAS: Re: Data loss

2023-05-27 Thread David Bremner
Paul Wise  writes:

> I think a better option is to detect if the search cache Maildir is
> actually a Maildir and doesn't contain any data that could be lost.
>
> I have attached three patches I created to improve notmuch-mutt safety.

If possible, please use git-send-email for future series. 

> +my %required = map { $_ => 1 } @required;
> +foreach my $d (@contents) {
> +-l "$maildir/$d" and die_dir( $maildir, "contains symlink $d");
> +-d "$maildir/$d" or die_dir( $maildir, "contains non-directory $d");
> +exists($required[$d]) or die_dir( $maildir, "contains directory $d");
> +}
> +}

This seems to have introduced a warning, and I think there's a bug.

% notmuch mutt search tag:inbox 
Argument "new" isn't numeric in array or hash lookup at /usr/bin/notmuch-mutt 
line 70.
Argument "cur" isn't numeric in array or hash lookup at /usr/bin/notmuch-mutt 
line 70.
Argument "tmp" isn't numeric in array or hash lookup at /usr/bin/notmuch-mutt 
line 70.

If I remember correctly you need to use {} for hash references in Perl.

>  
>  # create an empty search cache maildir (if missing) or empty existing one
>  sub empty_search_cache_maildir($) {
>  my ($maildir) = (@_);
> +check_search_cache_maildir($maildir);
>  rmtree($maildir) if (-d $maildir);
>  my $folder = new Mail::Box::Maildir(folder => $maildir,
>   create => 1);

It might clearer to use the return value from (a possibly renamed
check_search_cache (then the -d can be eliminated / folded into the new
function).
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] notmuch-mutt: check that the search cache Maildir is not a real Maildir WAS: Re: Data loss

2023-05-23 Thread Paul Wise
David Bremner wrote:

> Carl Worth  writes:
> 
> > What it could also do is create some placeholder file like
> > .NOTMUCH-MUTT-OUTPUT-DIR when it writes its output. And then it could
> > check for that file's existence before removing a directory.
> 
> Sounds reasonable to me. Would someone like to make a patch for
> notmuch-mutt?

This has the problem that the migration from existing search cache
Maildirs to the new setup needs users to do manual work and that they
or something else could later modify the migrated Maildir by adding
real mail data or subfolders containing real data.

I think a better option is to detect if the search cache Maildir is
actually a Maildir and doesn't contain any data that could be lost.

I have attached three patches I created to improve notmuch-mutt safety.

-- 
bye,
pabs

https://bonedaddy.net/pabs3/
From 22dad230dc368ff09cef2fd1eddd10ba89d41d16 Mon Sep 17 00:00:00 2001
From: Paul Wise 
Date: Wed, 24 May 2023 08:26:38 +0800
Subject: [PATCH 1/3] notmuch-mutt: clarify the empty Maildir function operates
 on search caches

Rename the function and adjust the documentation comment.
---
 contrib/notmuch-mutt/notmuch-mutt | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
index d1e2c084..eef1dea5 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -27,8 +27,8 @@ $xdg_cache_dir = $ENV{XDG_CACHE_HOME} if $ENV{XDG_CACHE_HOME};
 my $cache_dir = "$xdg_cache_dir/notmuch/mutt";
 
 
-# create an empty maildir (if missing) or empty an existing maildir"
-sub empty_maildir($) {
+# create an empty search cache maildir (if missing) or empty existing one
+sub empty_search_cache_maildir($) {
 my ($maildir) = (@_);
 rmtree($maildir) if (-d $maildir);
 my $folder = new Mail::Box::Maildir(folder => $maildir,
@@ -46,7 +46,7 @@ sub search($$$) {
 push @args, "--duplicate=1" if $remove_dups;
 push @args, $query;
 
-empty_maildir($maildir);
+empty_search_cache_maildir($maildir);
 open my $pipe, '-|', @args or die "Running @args failed: $!\n";
 while (<$pipe>) {
 	chomp;
@@ -121,7 +121,7 @@ sub thread_action($$@) {
 
 my $mid = get_message_id();
 if (! defined $mid) {
-	empty_maildir($results_dir);
+	empty_search_cache_maildir($results_dir);
 	die "notmuch-mutt: cannot find Message-Id, abort.\n";
 }
 my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid");
-- 
2.40.1

From 4cb6a83e634b4c2dbbaa1099811cf84d65627029 Mon Sep 17 00:00:00 2001
From: Paul Wise 
Date: Wed, 24 May 2023 08:24:02 +0800
Subject: [PATCH 2/3] notmuch-mutt: do not clear search cache Maildir when
 nothing is found

The previous results might be useful to the user but
an empty directory definitely isn't useful.
---
 contrib/notmuch-mutt/notmuch-mutt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
index eef1dea5..9badc59c 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -121,7 +121,6 @@ sub thread_action($$@) {
 
 my $mid = get_message_id();
 if (! defined $mid) {
-	empty_search_cache_maildir($results_dir);
 	die "notmuch-mutt: cannot find Message-Id, abort.\n";
 }
 my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid");
-- 
2.40.1

From 46036801970d43c4aee684a46ff0b0e0649e7cfd Mon Sep 17 00:00:00 2001
From: Paul Wise 
Date: Wed, 24 May 2023 06:22:01 +0800
Subject: [PATCH 3/3] notmuch-mutt: check that the search cache Maildir is not
 a real Maildir

This prevents data loss when users configure the search cache Maildir to be a
real Maildir containing their real mail data, since the search cache Maildir
is expected to contain only symlinks to the real mail data.

Prevents: 
---
 contrib/notmuch-mutt/notmuch-mutt | 46 +++
 1 file changed, 46 insertions(+)

diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
index 9badc59c..2569d055 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -13,6 +13,7 @@ use warnings;
 
 use File::Path;
 use File::Basename;
+use File::Find;
 use Getopt::Long qw(:config no_getopt_compat);
 use Mail::Header;
 use Mail::Box::Maildir;
@@ -26,10 +27,55 @@ my $xdg_cache_dir = "$ENV{HOME}/.cache";
 $xdg_cache_dir = $ENV{XDG_CACHE_HOME} if $ENV{XDG_CACHE_HOME};
 my $cache_dir = "$xdg_cache_dir/notmuch/mutt";
 
+sub die_dir($$) {
+my ($maildir, $error) = @_;
+die "notmuch-mutt: search cache maildir $maildir $error\n".
+"Please ensure that the notmuch-mutt search cache Maildir\n".
+"contains no subfolders or real mail data, only symlinks to mail\n";
+}
+
+sub die_subdir($$$) {
+my ($m

Re: Data loss

2023-04-08 Thread David Bremner
Carl Worth  writes:
>
> What it could also do is create some placeholder file like
> .NOTMUCH-MUTT-OUTPUT-DIR when it writes its output. And then it could
> check for that file's existence before removing a directory.
>

Sounds reasonable to me. Would someone like to make a patch for
notmuch-mutt?

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-04 Thread Carl Worth
On Tue, Apr 04 2023, Michael J. Gruber wrote:
>> It's really unfortunate if notmuch-mutt makes it that easy to throw away
>> your email.
>>
>> That sounds like a nasty bug that should be fixed in that program.
>
> To be fair to notmuch-mutt:
> ```
> --output-dir DIR
>
> Store search results as (symlink) messages under maildir DIR. Beware: DIR will
> be overwritten. (Default: F<~/.cache/notmuch/mutt/results/>)
> ```
> So the default is safe, and the warning is there. It would be a bug
> only if notmuch-mutt descended up and deleted a root dir or such.

OK. It's definitely acting as documented. So maybe "bug" was a little
harsh in my description.

It could still be made safer, and I think it would be a good idea to
change it.

For example, notmuch-mutt currently happily creates a directory that
doesn't already exists. That's safe and good.

What it could also do is create some placeholder file like
.NOTMUCH-MUTT-OUTPUT-DIR when it writes its output. And then it could
check for that file's existence before removing a directory.

-Carl
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-04 Thread Michael J Gruber
Am Di., 4. Apr. 2023 um 00:54 Uhr schrieb Carl Worth :
>
> Ouch.
>

Yes, we're feeling with you, Fulvio :|

> It's really unfortunate if notmuch-mutt makes it that easy to throw away
> your email.
>
> That sounds like a nasty bug that should be fixed in that program.

To be fair to notmuch-mutt:
```
--output-dir DIR

Store search results as (symlink) messages under maildir DIR. Beware: DIR will
be overwritten. (Default: F<~/.cache/notmuch/mutt/results/>)
```
So the default is safe, and the warning is there. It would be a bug
only if notmuch-mutt descended up and deleted a root dir or such.
Maybe naming the option `scratch-dir` or `cache-dir` or such could
have helped, but otoh the name of the default is there.

Note that neomutt incorporates notmuch-mutt's functionality, it might
be a better choice for this and other reasons.

> As for recovering, I suppose there _is_ a fair amount of detail in your
> notmuch index from all of the position-indexed terms, (as long as you
> haven't run "notmuch new" again since the mail was deleted).
>
> If you still have a large Xapian database in the notmuch database
> directory, it would be theoretically possible to recover a lot of the
> email content. But I don't know that anyone has ever written a recovery
> tool to help with that process.
>

That is an interesting question for the insiders, indeed - can e-mail
bodies be recovered fully (minus capitalisation, stemming)?

In Fulvio's case I would try a file-system dump (if it's not too late)
and a recovery tool depending on the fs type.

Michael
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-03 Thread Carl Worth
Ouch.

It's really unfortunate if notmuch-mutt makes it that easy to throw away
your email.

That sounds like a nasty bug that should be fixed in that program.

As for recovering, I suppose there _is_ a fair amount of detail in your
notmuch index from all of the position-indexed terms, (as long as you
haven't run "notmuch new" again since the mail was deleted).

If you still have a large Xapian database in the notmuch database
directory, it would be theoretically possible to recover a lot of the
email content. But I don't know that anyone has ever written a recovery
tool to help with that process.

-Carl

On Mon, Apr 03 2023, Fulvio Pizzigoni wrote:
> On Mon, Apr 03, 2023 at 08:39:02PM +0200, Michael J Gruber wrote:
>> Am Mo., 3. Apr. 2023 um 20:17 Uhr schrieb Fulvio Pizzigoni
>> :
>> >
>> >
>> >
>> >
>> >
>> >
>> > Hi Carl e thanks for your prompt answer.
>> >
>> > As you suggested, I add notmuch@notmuchmail.org email as well.
>> >
>> > This is what I did:
>> > fulvio@linux:~$ notmuch setup
>> > Your full name [fulvio]:
>> > Your primary email address [my address]: return
>> > Additional email address [Press 'Enter' if none]: return
>> > Top-level directory of your email archive [/home/fulvio/.mutt]: return
>> > Tags to apply to all new messages (separated by spaces) [unread inbox]: 
>> > return
>> > Tags to exclude when searching messages (separated by spaces) [deleted 
>> > spam]: return
>> > fulvio@linux:~$
>> >
>> > After this my .mutt directory (~ 4 GB di mail-boxess) appears so:
>> > fulvio@linux:~$ ll .mutt
>> > totale 12
>> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 cur
>> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 new
>> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 tmp
>> > fulvio@linux:~$ du -h .mutt
>> > 4,0K.mutt/new
>> > 4,0K.mutt/tmp
>> > 4,0K.mutt/cur
>> > 16K .mutt
>> >
>> > That's all.
>> >
>> > Terrible!
>> >
>> > What happened?
>> >
>> > Thanks in advance.
>> >
>> > Fulvio
>
> Hi Michael.
>
>> 
>> First of all: Do you have a back-up? 
>
> G, no :-((
>
>> 
>> notmuch itself does not delete mails, as Carl pointed out. In addition
>> to notmuch you mentioned notmuch-mutt. Did you run that manually or
>> using some mutt config? 
>
> Yes I did this manually:
> fulvio@linux:~$ notmuch-mutt -o .mutt/ search 
>
>> It creates a maildir of symlinks with search
>> results. In order to do so, it deletes the maildir ... 
>
> I think that's the cause.
>
> ... And I think it's irreparable. Am I wrong?
>
> Thanks in advance.
>
> Fulvio
>
>> Usually this  sits in a cache dir, though.
>> 
>> Michael
>> 
>> > On Mon, Apr 03, 2023 at 09:27:22AM -0700, Carl Worth wrote:
>> > > Hi Fulvio,
>> > >
>> > > I've never used notmuch-mutt.
>> > >
>> > > But notmuch itself doesn't delete any mail. It's really paranoid that
>> > > way, (knowing how valuable mail is).
>> > >
>> > > I would suggest you write an email to the notmuch@notmuchmail.org
>> > > mailing list where you will be able to reach more people likely to have
>> > > experience with all of the software you were using.
>> > >
>> > > And if you could provide more details on the actual steps you used, that
>> > > would be useful. For example, you said "configuration process" and "at
>> > > the end". But what actual commands were you running on those steps, for
>> > > example?
>> > >
>> > > -Carl
>> > >
>> > > On Mon, Apr 03 2023, Fulvio Pizzigoni wrote:
>> > > > Hi.
>> > > >
>> > > > I have installed packages notmuch and notmuch-mutt.
>> > > >
>> > > > During configuration process I have indicated the directory used from
>> > > > Mutt for your mail-boxes.
>> > > >
>> > > > The configuration process have not indicated any allert.
>> > > >
>> > > > At the end the mail-boxes in that directory was removed; 3 new
>> > > > empty sub-directory were created: cur, new, tmp.
>> > > >
>> > > > Was the data irremediably lost?
>> > > >
>> > > > Thanks in advance.
>> > > >
>> > > > Fulvio Pizzigoni
>> > ___
>> > notmuch mailing list -- notmuch@notmuchmail.org
>> > To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-03 Thread Fulvio Pizzigoni
On Mon, Apr 03, 2023 at 08:39:02PM +0200, Michael J Gruber wrote:
> Am Mo., 3. Apr. 2023 um 20:17 Uhr schrieb Fulvio Pizzigoni
> :
> >
> >
> >
> >
> >
> >
> > Hi Carl e thanks for your prompt answer.
> >
> > As you suggested, I add notmuch@notmuchmail.org email as well.
> >
> > This is what I did:
> > fulvio@linux:~$ notmuch setup
> > Your full name [fulvio]:
> > Your primary email address [my address]: return
> > Additional email address [Press 'Enter' if none]: return
> > Top-level directory of your email archive [/home/fulvio/.mutt]: return
> > Tags to apply to all new messages (separated by spaces) [unread inbox]: 
> > return
> > Tags to exclude when searching messages (separated by spaces) [deleted 
> > spam]: return
> > fulvio@linux:~$
> >
> > After this my .mutt directory (~ 4 GB di mail-boxess) appears so:
> > fulvio@linux:~$ ll .mutt
> > totale 12
> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 cur
> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 new
> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 tmp
> > fulvio@linux:~$ du -h .mutt
> > 4,0K.mutt/new
> > 4,0K.mutt/tmp
> > 4,0K.mutt/cur
> > 16K .mutt
> >
> > That's all.
> >
> > Terrible!
> >
> > What happened?
> >
> > Thanks in advance.
> >
> > Fulvio

Hi Michael.

> 
> First of all: Do you have a back-up? 

G, no :-((

> 
> notmuch itself does not delete mails, as Carl pointed out. In addition
> to notmuch you mentioned notmuch-mutt. Did you run that manually or
> using some mutt config? 

Yes I did this manually:
fulvio@linux:~$ notmuch-mutt -o .mutt/ search 

> It creates a maildir of symlinks with search
> results. In order to do so, it deletes the maildir ... 

I think that's the cause.

... And I think it's irreparable. Am I wrong?

Thanks in advance.

Fulvio

> Usually this  sits in a cache dir, though.
> 
> Michael
> 
> > On Mon, Apr 03, 2023 at 09:27:22AM -0700, Carl Worth wrote:
> > > Hi Fulvio,
> > >
> > > I've never used notmuch-mutt.
> > >
> > > But notmuch itself doesn't delete any mail. It's really paranoid that
> > > way, (knowing how valuable mail is).
> > >
> > > I would suggest you write an email to the notmuch@notmuchmail.org
> > > mailing list where you will be able to reach more people likely to have
> > > experience with all of the software you were using.
> > >
> > > And if you could provide more details on the actual steps you used, that
> > > would be useful. For example, you said "configuration process" and "at
> > > the end". But what actual commands were you running on those steps, for
> > > example?
> > >
> > > -Carl
> > >
> > > On Mon, Apr 03 2023, Fulvio Pizzigoni wrote:
> > > > Hi.
> > > >
> > > > I have installed packages notmuch and notmuch-mutt.
> > > >
> > > > During configuration process I have indicated the directory used from
> > > > Mutt for your mail-boxes.
> > > >
> > > > The configuration process have not indicated any allert.
> > > >
> > > > At the end the mail-boxes in that directory was removed; 3 new
> > > > empty sub-directory were created: cur, new, tmp.
> > > >
> > > > Was the data irremediably lost?
> > > >
> > > > Thanks in advance.
> > > >
> > > > Fulvio Pizzigoni
> > ___
> > notmuch mailing list -- notmuch@notmuchmail.org
> > To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-03 Thread Fulvio Pizzigoni
On Mon, Apr 03, 2023 at 03:38:21PM -0300, David Bremner wrote:
> Fulvio Pizzigoni  writes:
> >
> > After this my .mutt directory (~ 4 GB di mail-boxess) appears so:
> > fulvio@linux:~$ ll .mutt
> > totale 12
> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 cur
> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 new
> > drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 tmp
> 
> Hi Fulvio;

Hi David.

> 
> I don't understand your situation yet, but I have a preliminary
> question.
> 
> Is the date on your computer more or less correct? 

Yes, it is.

> You mention the
> directories cur, new, and tmp being created by running notmuch setup;

It is correct.
 
> on the other hand your listing above shows they already existed in
> February.

It is the date when I did the setup.

Thanks in advance.

Fulvio

> 
> d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-03 Thread Michael J Gruber
Am Mo., 3. Apr. 2023 um 20:17 Uhr schrieb Fulvio Pizzigoni
:
>
>
>
>
>
>
> Hi Carl e thanks for your prompt answer.
>
> As you suggested, I add notmuch@notmuchmail.org email as well.
>
> This is what I did:
> fulvio@linux:~$ notmuch setup
> Your full name [fulvio]:
> Your primary email address [my address]: return
> Additional email address [Press 'Enter' if none]: return
> Top-level directory of your email archive [/home/fulvio/.mutt]: return
> Tags to apply to all new messages (separated by spaces) [unread inbox]: return
> Tags to exclude when searching messages (separated by spaces) [deleted spam]: 
> return
> fulvio@linux:~$
>
> After this my .mutt directory (~ 4 GB di mail-boxess) appears so:
> fulvio@linux:~$ ll .mutt
> totale 12
> drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 cur
> drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 new
> drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 tmp
> fulvio@linux:~$ du -h .mutt
> 4,0K.mutt/new
> 4,0K.mutt/tmp
> 4,0K.mutt/cur
> 16K .mutt
>
> That's all.
>
> Terrible!
>
> What happened?
>
> Thanks in advance.
>
> Fulvio

First of all: Do you have a back-up?

notmuch itself does not delete mails, as Carl pointed out. In addition
to notmuch you mentioned notmuch-mutt. Did you run that manually or
using some mutt config? It creates a maildir of symlinks with search
results. In order to do so, it deletes the maildir ... Usually this
sits in a cache dir, though.

Michael

> On Mon, Apr 03, 2023 at 09:27:22AM -0700, Carl Worth wrote:
> > Hi Fulvio,
> >
> > I've never used notmuch-mutt.
> >
> > But notmuch itself doesn't delete any mail. It's really paranoid that
> > way, (knowing how valuable mail is).
> >
> > I would suggest you write an email to the notmuch@notmuchmail.org
> > mailing list where you will be able to reach more people likely to have
> > experience with all of the software you were using.
> >
> > And if you could provide more details on the actual steps you used, that
> > would be useful. For example, you said "configuration process" and "at
> > the end". But what actual commands were you running on those steps, for
> > example?
> >
> > -Carl
> >
> > On Mon, Apr 03 2023, Fulvio Pizzigoni wrote:
> > > Hi.
> > >
> > > I have installed packages notmuch and notmuch-mutt.
> > >
> > > During configuration process I have indicated the directory used from
> > > Mutt for your mail-boxes.
> > >
> > > The configuration process have not indicated any allert.
> > >
> > > At the end the mail-boxes in that directory was removed; 3 new
> > > empty sub-directory were created: cur, new, tmp.
> > >
> > > Was the data irremediably lost?
> > >
> > > Thanks in advance.
> > >
> > > Fulvio Pizzigoni
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-03 Thread David Bremner
Fulvio Pizzigoni  writes:
>
> After this my .mutt directory (~ 4 GB di mail-boxess) appears so:
> fulvio@linux:~$ ll .mutt
> totale 12
> drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 cur
> drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 new
> drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 tmp

Hi Fulvio;

I don't understand your situation yet, but I have a preliminary
question.

Is the date on your computer more or less correct? You mention the
directories cur, new, and tmp being created by running notmuch setup; on
the other hand your listing above shows they already existed in
February.

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Data loss

2023-04-03 Thread Fulvio Pizzigoni






Hi Carl e thanks for your prompt answer.

As you suggested, I add notmuch@notmuchmail.org email as well.

This is what I did:
fulvio@linux:~$ notmuch setup 
Your full name [fulvio]: 
Your primary email address [my address]: return
Additional email address [Press 'Enter' if none]: return
Top-level directory of your email archive [/home/fulvio/.mutt]: return
Tags to apply to all new messages (separated by spaces) [unread inbox]: return
Tags to exclude when searching messages (separated by spaces) [deleted spam]: 
return
fulvio@linux:~$

After this my .mutt directory (~ 4 GB di mail-boxess) appears so:
fulvio@linux:~$ ll .mutt
totale 12
drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 cur
drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 new
drwxr-xr-x 2 fulvio fulvio 4096 18 feb 20.32 tmp
fulvio@linux:~$ du -h .mutt
4,0K.mutt/new
4,0K.mutt/tmp
4,0K.mutt/cur
16K .mutt

That's all.

Terrible!

What happened?

Thanks in advance.

Fulvio


On Mon, Apr 03, 2023 at 09:27:22AM -0700, Carl Worth wrote:
> Hi Fulvio,
> 
> I've never used notmuch-mutt.
> 
> But notmuch itself doesn't delete any mail. It's really paranoid that
> way, (knowing how valuable mail is).
> 
> I would suggest you write an email to the notmuch@notmuchmail.org
> mailing list where you will be able to reach more people likely to have
> experience with all of the software you were using.
> 
> And if you could provide more details on the actual steps you used, that
> would be useful. For example, you said "configuration process" and "at
> the end". But what actual commands were you running on those steps, for
> example?
> 
> -Carl
> 
> On Mon, Apr 03 2023, Fulvio Pizzigoni wrote:
> > Hi.
> >
> > I have installed packages notmuch and notmuch-mutt.
> >
> > During configuration process I have indicated the directory used from 
> > Mutt for your mail-boxes.
> >
> > The configuration process have not indicated any allert.
> >
> > At the end the mail-boxes in that directory was removed; 3 new
> > empty sub-directory were created: cur, new, tmp.
> >
> > Was the data irremediably lost?
> >
> > Thanks in advance.
> >
> > Fulvio Pizzigoni
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-04-13 Thread Carl Worth
On Tue, 30 Mar 2010 10:23:23 +0200, Michal Sojka  wrote:
> When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
> to removal of messages from the database even if the files were not
> removed.
> 
> It happened at least once to me.
> 
> Signed-off-by: Michal Sojka 

Thanks so much, Michal!

This was a very bad bug that I'm sure I introduced myself when
implementing rename support.

Thanks to Sebastian for reminding me to pick this up for the 0.2
release.

And, everyone, if I'm behind on patches, (which has always been the case
so far with this project...), please feel free to make plenty of noise
when there are known fixes for data-loss bugs. We really shouldn't let
those sit for a couple of weeks!

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100413/665624a9/attachment.pgp>


Re: [notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-04-13 Thread Carl Worth
On Tue, 30 Mar 2010 10:23:23 +0200, Michal Sojka sojk...@fel.cvut.cz wrote:
 When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
 to removal of messages from the database even if the files were not
 removed.
 
 It happened at least once to me.
 
 Signed-off-by: Michal Sojka sojk...@fel.cvut.cz

Thanks so much, Michal!

This was a very bad bug that I'm sure I introduced myself when
implementing rename support.

Thanks to Sebastian for reminding me to pick this up for the 0.2
release.

And, everyone, if I'm behind on patches, (which has always been the case
so far with this project...), please feel free to make plenty of noise
when there are known fixes for data-loss bugs. We really shouldn't let
those sit for a couple of weeks!

-Carl


pgpv1jX4K9zi0.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-30 Thread Michal Sojka
When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
to removal of messages from the database even if the files were not
removed.

It happened at least once to me.

Signed-off-by: Michal Sojka 
---
 notmuch-new.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..5ade168 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -454,6 +454,9 @@ add_files_recursive (notmuch_database_t *notmuch,
next = NULL;
 }

+if (interrupted)
+   goto DONE;
+
 /* Now that we've walked the whole filesystem list, anything left
  * over in the database lists has been deleted. */
 while (notmuch_filenames_valid (db_files))
-- 
1.7.0.2



[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-30 Thread Michal Sojka
On Mon, 29 Mar 2010, spaetz wrote:
> 
> hehe, this version compiles but has the logic inverted. Removing the ! from
> your patch makes it actually work as intended :--).

Right! I should definitely be more careful even for such a trivial
patches :) It's interesting, that in my branch, I have no negation.

I send the patch once again.

Michal


Re: [notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-30 Thread Michal Sojka
On Mon, 29 Mar 2010, spaetz wrote:
 
 hehe, this version compiles but has the logic inverted. Removing the ! from
 your patch makes it actually work as intended :--).

Right! I should definitely be more careful even for such a trivial
patches :) It's interesting, that in my branch, I have no negation.

I send the patch once again.

Michal
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-30 Thread Michal Sojka
When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
to removal of messages from the database even if the files were not
removed.

It happened at least once to me.

Signed-off-by: Michal Sojka sojk...@fel.cvut.cz
---
 notmuch-new.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..5ade168 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -454,6 +454,9 @@ add_files_recursive (notmuch_database_t *notmuch,
next = NULL;
 }
 
+if (interrupted)
+   goto DONE;
+
 /* Now that we've walked the whole filesystem list, anything left
  * over in the database lists has been deleted. */
 while (notmuch_filenames_valid (db_files))
-- 
1.7.0.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-29 Thread spaetz

hehe, this version compiles but has the logic inverted. Removing the ! from
your patch makes it actually work as intended :--).
-- 
View this message in context: 
http://n3.nabble.com/PATCH-Prevent-data-loss-caused-by-SIGINT-during-notmuch-new-tp677501p684691.html
Sent from the notmuch mailing list archive at Nabble.com.


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-29 Thread Sebastian Spaeth
> Oh, sorry. I thought it is so trivial, that I didn't even compile it for
> master. The right version is here:

Thanks, that worked fine now. I pushed it to my branch.

Sebastian


Re: [notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-29 Thread Sebastian Spaeth
 Oh, sorry. I thought it is so trivial, that I didn't even compile it for
 master. The right version is here:

Thanks, that worked fine now. I pushed it to my branch.

Sebastian
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-29 Thread spaetz

hehe, this version compiles but has the logic inverted. Removing the ! from
your patch makes it actually work as intended :--).
-- 
View this message in context: 
http://n3.nabble.com/PATCH-Prevent-data-loss-caused-by-SIGINT-during-notmuch-new-tp677501p684691.html
Sent from the notmuch mailing list archive at Nabble.com.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-28 Thread Michal Sojka
On Sun, 28 Mar 2010, Sebastian Spaeth wrote:
> On Sun, 28 Mar 2010 00:37:00 +0100, "Sebastian Spaeth"  SSpaeth.de> wrote:
> > On Fri, 26 Mar 2010 22:18:13 +0100, Michal Sojka  
> > wrote:
> > > When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
> > > to removal of messages from the database even if the files were not
> > > removed.
> 
> CC -O2notmuch-new.o
> notmuch-new.c: In function 'add_files_recursive':
> notmuch-new.c:519: error: 'add_files_state_t' has no member named 
> 'interrupted'
> make: *** [notmuch-new.o] Error 1
> 
> I have not checked the code yet, but simply applying this patch make the
> compile fail.

Oh, sorry. I thought it is so trivial, that I didn't even compile it for
master. The right version is here:

--8<---cut here---start->8---
>From 117de1fcc316a4792244a36b68e38215ff2a5bdc Mon Sep 17 00:00:00 2001
From: Michal Sojka <sojk...@fel.cvut.cz>
Date: Fri, 26 Mar 2010 22:16:26 +0100
Subject: [PATCH v2] Prevent data loss caused by SIGINT during notmuch new

When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
to removal of messages from the database even if the files were not
removed.

It happened at least once to me.

Signed-off-by: Michal Sojka 
---
 notmuch-new.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..109bef2 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -454,6 +454,9 @@ add_files_recursive (notmuch_database_t *notmuch,
next = NULL;
 }

+if (! interrupted)
+   goto DONE;
+
 /* Now that we've walked the whole filesystem list, anything left
  * over in the database lists has been deleted. */
 while (notmuch_filenames_valid (db_files))
-- 
1.7.0.2


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-28 Thread Sebastian Spaeth
On Sun, 28 Mar 2010 00:37:00 +0100, "Sebastian Spaeth"  wrote:
> On Fri, 26 Mar 2010 22:18:13 +0100, Michal Sojka  
> wrote:
> > When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
> > to removal of messages from the database even if the files were not
> > removed.

CC -O2  notmuch-new.o
notmuch-new.c: In function 'add_files_recursive':
notmuch-new.c:519: error: 'add_files_state_t' has no member named 'interrupted'
make: *** [notmuch-new.o] Error 1

I have not checked the code yet, but simply applying this patch make the
compile fail.

Sebastian


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-28 Thread Sebastian Spaeth
On Fri, 26 Mar 2010 22:18:13 +0100, Michal Sojka  wrote:
> When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
> to removal of messages from the database even if the files were not
> removed.

Thanks, applied in my feature-all branch.

Sebastian


Re: [notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-27 Thread Sebastian Spaeth
On Fri, 26 Mar 2010 22:18:13 +0100, Michal Sojka sojk...@fel.cvut.cz wrote:
 When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
 to removal of messages from the database even if the files were not
 removed.

Thanks, applied in my feature-all branch.

Sebastian
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-27 Thread Michal Sojka
On Sun, 28 Mar 2010, Sebastian Spaeth wrote:
 On Sun, 28 Mar 2010 00:37:00 +0100, Sebastian Spaeth sebast...@sspaeth.de 
 wrote:
  On Fri, 26 Mar 2010 22:18:13 +0100, Michal Sojka sojk...@fel.cvut.cz 
  wrote:
   When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
   to removal of messages from the database even if the files were not
   removed.
 
 CC -O2notmuch-new.o
 notmuch-new.c: In function 'add_files_recursive':
 notmuch-new.c:519: error: 'add_files_state_t' has no member named 
 'interrupted'
 make: *** [notmuch-new.o] Error 1
 
 I have not checked the code yet, but simply applying this patch make the
 compile fail.

Oh, sorry. I thought it is so trivial, that I didn't even compile it for
master. The right version is here:

--8---cut here---start-8---
From 117de1fcc316a4792244a36b68e38215ff2a5bdc Mon Sep 17 00:00:00 2001
From: Michal Sojka sojk...@fel.cvut.cz
Date: Fri, 26 Mar 2010 22:16:26 +0100
Subject: [PATCH v2] Prevent data loss caused by SIGINT during notmuch new

When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
to removal of messages from the database even if the files were not
removed.

It happened at least once to me.

Signed-off-by: Michal Sojka sojk...@fel.cvut.cz
---
 notmuch-new.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..109bef2 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -454,6 +454,9 @@ add_files_recursive (notmuch_database_t *notmuch,
next = NULL;
 }
 
+if (! interrupted)
+   goto DONE;
+
 /* Now that we've walked the whole filesystem list, anything left
  * over in the database lists has been deleted. */
 while (notmuch_filenames_valid (db_files))
-- 
1.7.0.2
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-26 Thread Michal Sojka
When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
to removal of messages from the database even if the files were not
removed.

It happened at least once to me.

Signed-off-by: Michal Sojka 
---
 notmuch-new.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..ae89654 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -454,6 +454,9 @@ add_files_recursive (notmuch_database_t *notmuch,
next = NULL;
 }

+if (state->interrupted)
+   goto DONE;
+
 /* Now that we've walked the whole filesystem list, anything left
  * over in the database lists has been deleted. */
 while (notmuch_filenames_valid (db_files))
-- 
1.7.0.2



[notmuch] [PATCH] Prevent data loss caused by SIGINT during notmuch new

2010-03-26 Thread Michal Sojka
When Ctrl-C is pressed in a wrong time during notmuch new, it can lead
to removal of messages from the database even if the files were not
removed.

It happened at least once to me.

Signed-off-by: Michal Sojka sojk...@fel.cvut.cz
---
 notmuch-new.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..ae89654 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -454,6 +454,9 @@ add_files_recursive (notmuch_database_t *notmuch,
next = NULL;
 }
 
+if (state-interrupted)
+   goto DONE;
+
 /* Now that we've walked the whole filesystem list, anything left
  * over in the database lists has been deleted. */
 while (notmuch_filenames_valid (db_files))
-- 
1.7.0.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch