//go:build notmuch // +build notmuch package notmuch import ( "fmt" "path/filepath" "strconv" "git.sr.ht/~rjarry/aerc/worker/types" ) func (w *worker) handleNotmuchEvent(et eventType) error { switch et.(type) { case *updateDirCounts: return w.handleUpdateDirCounts() default: return errUnsupported } } func (w *worker) handleUpdateDirCounts() error { err := w.db.Connect() if err != nil { return err } defer w.db.Close() if w.store != nil { folders, err := w.store.FolderMap() if err != nil { w.w.Errorf("failed listing directories: %v", err) return err } for name := range folders { folder := filepath.Join(w.maildirAccountPath, name) query := fmt.Sprintf("folder:%s", strconv.Quote(folder)) w.w.PostMessage(&types.DirectoryInfo{ Info: w.getDirectoryInfo(name, query), }, nil) } } for name, query := range w.nameQueryMap { w.w.PostMessage(&types.DirectoryInfo{ Info: w.getDirectoryInfo(name, query), }, nil) } return nil }