summary refs log tree commit diff stats
path: root/worker/maildir/worker.go
diff options
context:
space:
mode:
authorGalen Abell <galen@galenabell.com>2020-03-03 08:45:06 -0500
committerReto Brunner <reto@labrat.space>2020-03-03 20:08:37 +0100
commit6ff3c7a1ba680506d77fc1fe8dfbf5b804a3fea7 (patch)
tree093c49f4dc7fbc80adedb5f6c05a76bc697e44b6 /worker/maildir/worker.go
parent68f179021d304d6edf939ecf5fc7d0d073b16152 (diff)
downloadaerc-6ff3c7a1ba680506d77fc1fe8dfbf5b804a3fea7.tar.gz
Mark sent messages as "seen" in maildir
- Add maildir flags to complement a messages imap flags
- Set the "seen" flag on sent messages when using the maildir backend
- Cleanup AppendMessage interface to use models.Flag for both IMAP and
  maildir
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r--worker/maildir/worker.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index 17123c6..2f96e6f 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -337,7 +337,7 @@ func (w *Worker) sort(uids []uint32, criteria []*types.SortCriterion) ([]uint32,
 
 func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error {
 	dir := w.c.Dir(msg.Directory)
-	if err := dir.Create(); err != nil {
+	if err := dir.Init(); err != nil {
 		w.worker.Logger.Printf("could not create directory %s: %v",
 			msg.Directory, err)
 		return err
@@ -510,15 +510,16 @@ func (w *Worker) handleCopyMessages(msg *types.CopyMessages) error {
 }
 
 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)
-	delivery, err := dest.NewDelivery()
+	_, writer, err := dest.Create(translateFlags(msg.Flags))
 	if err != nil {
-		w.worker.Logger.Printf("could not deliver message to %s: %v",
+		w.worker.Logger.Printf("could not create message at %s: %v",
 			msg.Destination, err)
 		return err
 	}
-	defer delivery.Close()
-	if _, err := io.Copy(delivery, msg.Reader); err != nil {
+	defer writer.Close()
+	if _, err := io.Copy(writer, msg.Reader); err != nil {
 		w.worker.Logger.Printf("could not write message to destination: %v", err)
 		return err
 	}