aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-02-23 11:40:17 -0500
committerRobin Jarry <robin@jarry.cc>2024-04-02 22:22:28 +0200
commit1ce82f50d0981a9ee047e75d94c7ab496070bd4a (patch)
tree72d835ad5da26eea6d5a6acbdd916640b75f1a4e /lib
parent54a72f83035bdf710368846e55a5b003ccab66cd (diff)
downloadaerc-1ce82f50d0981a9ee047e75d94c7ab496070bd4a.tar.gz
notmuch: add strategies for multi-file messages
A single notmuch message can represent multiple files. As a result, file-based operations like move, copy, and delete can be ambiguous. Add a new account config option, multi-file-strategy, to tell aerc how to handle these ambiguous cases. Also add options to relevant commands to set the multi-file strategy on a per-invocation basis. If no multi-file strategy is set, refuse to take file-based actions on multi-file messages. This default behavior is mostly the same as aerc's previous behavior, but a bit stricter in some cases which previously tried to be smart about multi-file operations (e.g., move and delete). Applying multi-file strategies to cross-account copy and move operations is not implemented. These operations will proceed as they have in the past -- aerc will copy/move a single file. However, for cross-account move operations, aerc will refuse to delete multiple files to prevent data loss as not all of the files are added to the destination account. See the changes to aerc-notmuch(5) for details on the currently supported multi-file strategies. Changelog-added: Tell aerc how to handle file-based operations on multi-file notmuch messages with the account config option `multi-file-strategy` and the `-m` flag to `:archive`, `:copy`, `:delete`, and `:move`. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Maarten Aertsen <maarten@nlnetlabs.nl> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 274e42ba..d11d280e 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -572,14 +572,14 @@ func (store *MessageStore) doThreadFolding(uid uint32, hide bool, toggle bool) e
return nil
}
-func (store *MessageStore) Delete(uids []uint32,
+func (store *MessageStore) Delete(uids []uint32, mfs *types.MultiFileStrategy,
cb func(msg types.WorkerMessage),
) {
for _, uid := range uids {
store.Deleted[uid] = nil
}
- store.worker.PostAction(&types.DeleteMessages{Uids: uids},
+ store.worker.PostAction(&types.DeleteMessages{Uids: uids, MultiFileStrategy: mfs},
func(msg types.WorkerMessage) {
if _, ok := msg.(*types.Error); ok {
store.revertDeleted(uids)
@@ -601,7 +601,7 @@ func (store *MessageStore) revertDeleted(uids []uint32) {
}
func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool,
- cb func(msg types.WorkerMessage),
+ mfs *types.MultiFileStrategy, cb func(msg types.WorkerMessage),
) {
if createDest {
store.worker.PostAction(&types.CreateDirectory{
@@ -611,8 +611,9 @@ func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool,
}
store.worker.PostAction(&types.CopyMessages{
- Destination: dest,
- Uids: uids,
+ Destination: dest,
+ Uids: uids,
+ MultiFileStrategy: mfs,
}, func(msg types.WorkerMessage) {
if _, ok := msg.(*types.Done); ok {
store.triggerMailAdded(dest)
@@ -622,7 +623,7 @@ func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool,
}
func (store *MessageStore) Move(uids []uint32, dest string, createDest bool,
- cb func(msg types.WorkerMessage),
+ mfs *types.MultiFileStrategy, cb func(msg types.WorkerMessage),
) {
for _, uid := range uids {
store.Deleted[uid] = nil
@@ -636,8 +637,9 @@ func (store *MessageStore) Move(uids []uint32, dest string, createDest bool,
}
store.worker.PostAction(&types.MoveMessages{
- Destination: dest,
- Uids: uids,
+ Destination: dest,
+ Uids: uids,
+ MultiFileStrategy: mfs,
}, func(msg types.WorkerMessage) {
switch msg.(type) {
case *types.Error: