aboutsummaryrefslogtreecommitdiffstats
path: root/worker/notmuch
diff options
context:
space:
mode:
authorinwit <inwit@sindominio.net>2022-11-25 22:19:54 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:59:44 +0100
commit29218a9b4bf9d7f22ce3e102a2694709be296493 (patch)
tree50a5bbbf0472ea4ec64f4162f3bcae44c35ddb11 /worker/notmuch
parentd547dca676553a83c077b34f735c9d2ff5d41dcd (diff)
downloadaerc-29218a9b4bf9d7f22ce3e102a2694709be296493.tar.gz
notmuch: allow moving single file messages
In notmuch, a message can be represented by several identical files across the maildir structure, which makes the operation of moving a message from a virtual folder (showing a notmuch query) to a maildir folder problematic if the number of files for that message is greater than 1. Since the move operation is unambiguous when the message is represented by a single file, allow moving messages in such cases. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch')
-rw-r--r--worker/notmuch/worker.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index b3022e4c..a4f5b5c8 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -797,16 +797,7 @@ func (w *worker) handleMoveMessages(msg *types.MoveMessages) error {
var moved []uint32
- // With notmuch, two identical files can be referenced under
- // the same index key, even if they exist in two different
- // folders. So in order to remove the message from the right
- // maildir folder we need to pass a hint to Move() so it
- // can act on the right file.
folders, _ := w.store.FolderMap()
- source, ok := folders[w.currentQueryName]
- if !ok {
- return fmt.Errorf("Can only move file from a maildir folder")
- }
// Only allow file to be moved to a maildir folder
dest, ok := folders[msg.Destination]
@@ -821,6 +812,20 @@ func (w *worker) handleMoveMessages(msg *types.MoveMessages) error {
log.Errorf("could not get message: %v", err)
break
}
+ filenames, err := m.db.MsgFilenames(m.key)
+ if err != nil {
+ return err
+ }
+ // In the future, it'd be nice if we could overload move with
+ // the possibility to affect some or all of the files
+ // corresponding to a message.
+ if len(filenames) > 1 {
+ return fmt.Errorf("Cannot move: message %d has multiple files", m.uid)
+ }
+ source, key := parseFilename(filenames[0])
+ if key == "" {
+ return fmt.Errorf("failed to parse message filename: %s", filenames[0])
+ }
if err := m.Move(source, dest); err != nil {
log.Errorf("could not copy message: %v", err)
break