From c7bfe4e490fb1fcf779edceb23c96301eb763b47 Mon Sep 17 00:00:00 2001 From: Julian Pidancet Date: Wed, 26 Oct 2022 22:29:04 +0200 Subject: notmuch: add maildir support By associating the notmuch database with a maildir store, we can add the Copy/Move/Delete operations on messages to the notmuch backend. This change assumes that the notmuch database location is also the root of the maildir store. In a previous change, we added the ability to dynamically add and remove message files to the notmuch DB. This change uses this facility to synchronize the database with the filesystem operations on maildir files. While it's still possible to use the query-map file to create virtual folders from notmuch search queries, the sidebar is now loaded with the folders found in the maildir store. With notmuch, two identical but distinct message files can be indexed in the database with the same key. This change takes extra care of only deleting or removing message files from the maildir corresponding to the folder that is currently selected (if any). Implements: https://todo.sr.ht/~rjarry/aerc/88 Fixes: https://todo.sr.ht/~rjarry/aerc/73 Signed-off-by: Julian Pidancet Acked-by: Robin Jarry Acked-by: Tim Culverhouse --- worker/notmuch/eventhandlers.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'worker/notmuch/eventhandlers.go') diff --git a/worker/notmuch/eventhandlers.go b/worker/notmuch/eventhandlers.go index 7b3c5174..764add0c 100644 --- a/worker/notmuch/eventhandlers.go +++ b/worker/notmuch/eventhandlers.go @@ -3,7 +3,12 @@ package notmuch -import "git.sr.ht/~rjarry/aerc/logging" +import ( + "fmt" + "strconv" + + "git.sr.ht/~rjarry/aerc/logging" +) func (w *worker) handleNotmuchEvent(et eventType) error { switch ev := et.(type) { @@ -15,6 +20,21 @@ func (w *worker) handleNotmuchEvent(et eventType) error { } func (w *worker) handleUpdateDirCounts(ev eventType) error { + folders, err := w.store.FolderMap() + if err != nil { + logging.Errorf("failed listing directories: %v", err) + return err + } + for name := range folders { + query := fmt.Sprintf("folder:%s", strconv.Quote(name)) + info, err := w.buildDirInfo(name, query, true) + if err != nil { + logging.Errorf("could not gather DirectoryInfo: %v", err) + continue + } + w.w.PostMessage(info, nil) + } + for name, query := range w.nameQueryMap { info, err := w.buildDirInfo(name, query, true) if err != nil { -- cgit