diff options
author | inwit <inwit@sindominio.net> | 2022-11-21 15:27:05 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-02 22:59:44 +0100 |
commit | ce664936fd0d8d4d69de50545b394877cfc76c0b (patch) | |
tree | c97878f0d4247d1beaf06ce5a4d76a0c6e8275d6 /worker/notmuch | |
parent | 29218a9b4bf9d7f22ce3e102a2694709be296493 (diff) | |
download | aerc-ce664936fd0d8d4d69de50545b394877cfc76c0b.tar.gz |
notmuch: preserve tags when moving messages
Keep the original tags when a message is moved from one maildir folder to
another.
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch')
-rw-r--r-- | worker/notmuch/message.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/worker/notmuch/message.go b/worker/notmuch/message.go index 8f8deffd..0fc85b00 100644 --- a/worker/notmuch/message.go +++ b/worker/notmuch/message.go @@ -244,6 +244,11 @@ func (m *Message) Move(srcDir, destDir maildir.Dir) error { return fmt.Errorf("no matching message file found in %s", string(srcDir)) } + tags, err := m.Tags() + if err != nil { + return err + } + // Remove encoded UID information from the key to prevent sync issues name := lib.StripUIDFromMessageFilename(filepath.Base(src)) dest := filepath.Join(string(destDir), "cur", name) @@ -256,8 +261,15 @@ func (m *Message) Move(srcDir, destDir maildir.Dir) error { return err } - _, err = m.db.IndexFile(dest) - return err + if _, err = m.db.IndexFile(dest); err != nil { + return err + } + + if err := m.ModifyTags(tags, nil); err != nil { + return err + } + + return nil } func parseFilename(filename string) (maildir.Dir, string) { |