aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-28 14:14:13 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-28 14:14:13 +0100
commit86528e42be06c0ece077deecd6b09e2150d9431a (patch)
treecb67c35d192d06c0f600adf180eb27783f5986cb /main.go
parent013a2ef2659d1296457bc6b12c49a9480aa3551e (diff)
downloadfeed2imap-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.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/main.go b/main.go
index 86a6ddf..26582b7 100644
--- a/main.go
+++ b/main.go
@@ -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)
})