diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-08-29 13:15:46 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-08-30 22:10:36 +0200 |
commit | 781820627f1cb87df898d1a7b5f3b56c6fa20b77 (patch) | |
tree | 1e3a3c0c7cb8dae048b8bbe2079a15a85455d553 /worker/notmuch/worker.go | |
parent | 3a55b8e6fd51c3dda1ea71c6806f2ee2d71c1065 (diff) | |
download | aerc-781820627f1cb87df898d1a7b5f3b56c6fa20b77.tar.gz |
notmuch: replace notmuch library with internal bindings
Replace the notmuch library used with our internal bindings.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch/worker.go')
-rw-r--r-- | worker/notmuch/worker.go | 19 |
1 files changed, 9 insertions, 10 deletions
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) } |