diff options
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) }) |