notmuchsync: handling of the deleted tag

Sebastian Spaeth Sebastian at SSpaeth.de
Mon Sep 20 08:09:25 PDT 2010


On 2010-09-18, Rob Browning wrote:
> I've been trying notmuchsync, and it's quite helpful, but I just ran
> across something that caused me a bit of concern.  I noticed that some
> messages were marked deleted that I'm fairly certain I didn't intend to
> delete.
> 
> My suspicion is that this is because I received two copies of the
> message and I marked one of them for deletion (expiry) in Gnus, but not
> the other one.  Since notmuch doesn't normally distinguish between two
> messages with the same id, I suspected that notmuchsync might not notice
> either.  Is that possible?

Yes, that is certainly possible. notmuchsync checks if a file should be
deleted ("pruning") like this:

1)Run notmuchsync --revsync (or -r) and it will examine your mail
files. If a mail is trashed (expired) according to maildir flags in its
filename, it will add the tag "deleted" to the mail's id in the notmuch
database. If you have multiple copies with the same message that tag is
now associated with the mail id, not the actual file.

2) Run notmuchsync --prune which runs the query: "tag:delete or
tag:deleted or tag:maildir::trashed" by default. 

To which notmuch returns a list of messages and a corresponding filename
for each id. If there are multiple messages with the same id, I think it
will return the first filename that was associated with that mail id, so
it is kind of random which file location gets returned.  The returned
file names are associated with the "deleted" tag - and thus - unlinked.

I am unsure how to handle this in a better way. What should notmuchsync
--prune do if it finds multiple mail files that are associated with a
"deleted" tag? And what should --revsync do when it finds a mail file
that is marked as expired. As long as notmuch only offers one data entry
per mail id, there will remain some ambiguity as to how to handle these.


If notmuch gave me at least all filenames that are associated with a
mail id, I could introduce a command line option "--prune --safe" which would
Sebastian

P.S. CC'ing the notmuch list as this is potentially an issue that
affects people.


More information about the notmuch mailing list