diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-06-21 22:13:03 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-06-22 10:55:25 +0200 |
commit | 822bd3620a456fefcdb828f2768c0677e4442f05 (patch) | |
tree | ce304de9f3e88599b557c4c3576d2656a5831348 /worker/notmuch/worker.go | |
parent | 0f37a0ce2cdc07a090e33bbe53b1b67081cce741 (diff) | |
download | aerc-822bd3620a456fefcdb828f2768c0677e4442f05.tar.gz |
lib: parse query-map and folder-map files
Combine the query-map and folder-map parsing functionality. Add tests.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch/worker.go')
-rw-r--r-- | worker/notmuch/worker.go | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index f47f3889..70dca1e2 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -4,7 +4,6 @@ package notmuch import ( - "bufio" "bytes" "context" "errors" @@ -610,22 +609,8 @@ func (w *worker) loadQueryMap(acctConfig *config.AccountConfig) error { return err } defer f.Close() - w.nameQueryMap = make(map[string]string) - scanner := bufio.NewScanner(f) - for scanner.Scan() { - line := scanner.Text() - if line == "" || line[0] == '#' { - continue - } - - split := strings.SplitN(line, "=", 2) - if len(split) != 2 { - return fmt.Errorf("%v: invalid line %q, want name=query", file, line) - } - w.nameQueryMap[strings.TrimSpace(split[0])] = split[1] - w.queryMapOrder = append(w.queryMapOrder, strings.TrimSpace(split[0])) - } - return nil + w.nameQueryMap, w.queryMapOrder, err = lib.ParseFolderMap(f) + return err } func (w *worker) loadExcludeTags( |