aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/worker.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-08-16 16:23:40 -0500
committerRobin Jarry <robin@jarry.cc>2022-08-22 15:46:54 +0200
commitaf72ca36072615f3afc79d7a3f28f82e381b618c (patch)
tree1c5f4353568cc683b8fb72d323797bc9b591ea3c /worker/maildir/worker.go
parent64e1a7ca933b404d3556e776d0373069c1a0b763 (diff)
downloadaerc-af72ca36072615f3afc79d7a3f28f82e381b618c.tar.gz
maildir: implement MoveMessages handling
Implement MoveMessages in the maildir worker. go-maildir supports Move operations by default, and is functionally equivalent to a OS-level rename. Creation date of the file is preserved by using Move, which is used by at least one maildir-to-IMAP synchronizer (isync/mbsync). The previous move method of copy-and-delete would reset the creation date of the message, and potentially cause sorting issues in other email clients. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r--worker/maildir/worker.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index e482f4e0..e85caacc 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -294,6 +294,8 @@ func (w *Worker) handleMessage(msg types.WorkerMessage) error {
return w.handleAnsweredMessages(msg)
case *types.CopyMessages:
return w.handleCopyMessages(msg)
+ case *types.MoveMessages:
+ return w.handleMoveMessages(msg)
case *types.AppendMessage:
return w.handleAppendMessage(msg)
case *types.SearchDirectory:
@@ -655,6 +657,20 @@ func (w *Worker) handleCopyMessages(msg *types.CopyMessages) error {
return nil
}
+func (w *Worker) handleMoveMessages(msg *types.MoveMessages) error {
+ dest := w.c.Dir(msg.Destination)
+ moved, err := w.c.MoveAll(dest, *w.selected, msg.Uids)
+ destInfo := w.getDirectoryInfo(msg.Destination)
+ w.worker.PostMessage(&types.DirectoryInfo{
+ Info: destInfo,
+ }, nil)
+ w.worker.PostMessage(&types.MessagesDeleted{
+ Message: types.RespondTo(msg),
+ Uids: moved,
+ }, nil)
+ return err
+}
+
func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error {
// since we are the "master" maildir process, we can modify the maildir directly
dest := w.c.Dir(msg.Destination)