aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--worker/maildir/container.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/worker/maildir/container.go b/worker/maildir/container.go
index c5ac04ac..52bbf837 100644
--- a/worker/maildir/container.go
+++ b/worker/maildir/container.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "regexp"
"sort"
"strings"
@@ -12,6 +13,10 @@ import (
"git.sr.ht/~rjarry/aerc/lib/uidstore"
)
+// uidReg matches filename encoded UIDs in maildirs synched with mbsync or
+// OfflineIMAP
+var uidReg = regexp.MustCompile(`,U=\d+`)
+
// A Container is a directory which contains other directories which adhere to
// the Maildir spec
type Container struct {
@@ -222,6 +227,12 @@ func (c *Container) moveMessage(dest maildir.Dir, src maildir.Dir, uid uint32) e
if !ok {
return fmt.Errorf("could not find key for message id %d", uid)
}
- err := src.Move(dest, key)
- return err
+ path, err := src.Filename(key)
+ if err != nil {
+ return fmt.Errorf("could not find path for message id %d", uid)
+ }
+ // Remove encoded UID information from the key to prevent sync issues
+ name := uidReg.ReplaceAllString(filepath.Base(path), "")
+ destPath := filepath.Join(string(dest), "cur", name)
+ return os.Rename(path, destPath)
}