From ce664936fd0d8d4d69de50545b394877cfc76c0b Mon Sep 17 00:00:00 2001 From: inwit Date: Mon, 21 Nov 2022 15:27:05 +0100 Subject: 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 Acked-by: Robin Jarry --- worker/notmuch/message.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'worker/notmuch') 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) { -- cgit