diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-02-28 14:14:13 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-02-28 14:14:13 +0100 |
commit | 86528e42be06c0ece077deecd6b09e2150d9431a (patch) | |
tree | cb67c35d192d06c0f600adf180eb27783f5986cb /main.go | |
parent | 013a2ef2659d1296457bc6b12c49a9480aa3551e (diff) | |
download | feed2imap-go-86528e42be06c0ece077deecd6b09e2150d9431a.tar.gz feed2imap-go-86528e42be06c0ece077deecd6b09e2150d9431a.tar.bz2 feed2imap-go-86528e42be06c0ece077deecd6b09e2150d9431a.zip |
Set up IMAP connections while fetching and filtering feeds
Diffstat (limited to '')
-rw-r--r-- | main.go | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -101,24 +101,32 @@ func run() error { return nil } - if success := state.Fetch(); success == 0 { - return fmt.Errorf("No successful feed fetch.") - } - - state.Filter() - + imapErr := make(chan error, 1) var c *imap.Client if !dryRun && !buildCache { - if c, err = imap.Connect(cfg.Target); err != nil { - return err - } + go func() { + var err error + c, err = imap.Connect(cfg.Target) + imapErr <- err + }() defer c.Disconnect() } + if success := state.Fetch(); success == 0 { + return fmt.Errorf("No successful feed fetch.") + } + + state.Filter() + if buildCache { state.Foreach(cache.CachedFeed.Commit) } else { + if !dryRun { + if err = <-imapErr; err != nil { + return err + } + } state.ForeachGo(func(f cache.CachedFeed) { processFeed(f, c, dryRun) }) |