diff options
author | Thorben Günther <admin@xenrox.net> | 2024-08-21 23:36:45 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-08-24 15:49:17 +0200 |
commit | 940deec546c3723ed850ff27678678728e90fb78 (patch) | |
tree | 6c6ee2d1a90f90320c01ecaa83df245454b765b4 /worker | |
parent | 2d9f949ac9a3369f81142ec7b138a5eadebafaeb (diff) | |
download | aerc-940deec546c3723ed850ff27678678728e90fb78.tar.gz |
notmuch: fix watcher path
The watcher path does not necessarily contain ".notmuch". From
notmuch-config(1):
Notmuch will store its database here,
(in sub-directory named .notmuch if database.mail_root is unset).
So we can simply check if the ".notmuch" folder exists and fallback to
the default path if it does not.
Signed-off-by: Thorben Günther <admin@xenrox.net>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker')
-rw-r--r-- | worker/notmuch/worker.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index f3a9ce8b..06c0cde6 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -12,7 +12,6 @@ import ( "net/url" "os" "os/exec" - "path" "path/filepath" "strconv" "strings" @@ -266,8 +265,20 @@ func (w *worker) handleConnect(msg *types.Connect) error { w.state = w.db.State() // 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) + var dbPath string + path := filepath.Join(w.db.Path(), ".notmuch", "xapian") + _, err := os.Stat(path) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + dbPath = filepath.Join(w.db.Path(), "xapian") + } else { + return fmt.Errorf("error locating notmuch db: %w", err) + } + } else { + dbPath = path + } + + err = w.watcher.Configure(dbPath) log.Tracef("Configuring watcher for path: %v", dbPath) if err != nil { return fmt.Errorf("error configuring watcher: %w", err) |