From 781820627f1cb87df898d1a7b5f3b56c6fa20b77 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 29 Aug 2023 13:15:46 -0500 Subject: notmuch: replace notmuch library with internal bindings Replace the notmuch library used with our internal bindings. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- worker/notmuch/worker.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'worker/notmuch/worker.go') diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index 73aa0efe..51de6ccb 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -144,6 +144,13 @@ func (w *worker) handleMessage(msg types.WorkerMessage) error { return w.setupErr } } + if w.db != nil { + err := w.db.Connect() + if err != nil { + return err + } + defer w.db.Close() + } switch msg := msg.(type) { case *types.Unsupported: @@ -236,16 +243,12 @@ func (w *worker) handleConfigure(msg *types.Configure) error { } func (w *worker) handleConnect(msg *types.Connect) error { - err := w.db.Connect() - if err != nil { - return err - } w.done(msg) w.emitLabelList() // Watch all the files in the xapian folder for changes. We'll debounce // changes, so catching multiple is ok dbPath := path.Join(w.db.Path(), ".notmuch", "xapian") - err = w.watcher.Configure(dbPath) + err := w.watcher.Configure(dbPath) if err != nil { return err } @@ -714,11 +717,7 @@ func (w *worker) emitMessageInfo(m *Message, } func (w *worker) emitLabelList() { - tags, err := w.db.ListTags() - if err != nil { - w.w.Errorf("could not load tags: %v", err) - return - } + tags := w.db.ListTags() w.w.PostMessage(&types.LabelList{Labels: tags}, nil) } -- cgit