From 822bd3620a456fefcdb828f2768c0677e4442f05 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Wed, 21 Jun 2023 22:13:03 +0200 Subject: lib: parse query-map and folder-map files Combine the query-map and folder-map parsing functionality. Add tests. Signed-off-by: Koni Marti Tested-by: Bence Ferdinandy Signed-off-by: Robin Jarry --- worker/notmuch/worker.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'worker/notmuch') 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( -- cgit