]> git.notmuchmail.org Git - notmuch/commit
lib: Remove the synchronization of 'T' flag with "deleted" tag.
authorCarl Worth <cworth@cworth.org>
Tue, 9 Nov 2010 23:48:46 +0000 (15:48 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 11 Nov 2010 10:35:03 +0000 (02:35 -0800)
commit2c262042ac174d7bc96d6035ab9c88bd0abe7f35
treed156482e8d467a0aa3068ff193b3dc5a8303c423
parent882b994c173475f8973d5f5a1c0d1c25e4f93818
lib: Remove the synchronization of 'T' flag with "deleted" tag.

Tags in a notmuch database affect all messages with the identical
message-ID. But maildir tags affect individual files. And since
multiple files can contain the identical message-ID, there is not a
one-to-one correspondence between messages affected by tags and flags.

This is particularly dangerous with the 'T' (== "trashed") maildir
flag and the corresponding "deleted" tag in the notmuch
database. Since these flags/tags are often used to trigger
irreversible deletion operations, the lack of one-to-one
correspondence can be potentially dangerous.

For example, consider the following sequence:

  1. A third-party application is used to identify duplicate messages
     in the mail store, and mark all-but-one of each duplicate with
     the 'T' flag for subsequent deletion.

  2. A "notmuch new" operation reads that 'T' flag, adding the
     "deleted" flag to the corresponding messages within the notmuch
     database.

  3. A subsequent notmuch operation, (such as a "notmuch dump; notmuch
     restore" cycle) synchronized the "deleted" tag back to the mail
     store, applying the 'T' flag to all(!) filenames with duplicate
     message IDs.

  4. A third-party application reads the 'T' flags and irreversibly
     deletes all mail messages which had any duplicates(!).

In order to avoid this scenario, we simply refuse to synchronize the
'T' flag with the "deleted" tag. Instead, applications can set 'T' and
act on it to delete files, or can set "deleted" and act on it to
delete files. But in either case the semantics are clear and there is
never dangerous propagation through the one-to-many mapping of notmuch
message objects to files.
lib/message.cc