diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-24 00:22:19 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-24 00:22:19 +0200 |
commit | c08aff21cd67cc27926a4cb1ca72ffe67e015ebf (patch) | |
tree | c9b0185424e0e74bc092a2606c6164c4e6698e48 /main.go | |
parent | 8467dbb9bd9960191f16def3ba43dcbde0fdda14 (diff) | |
download | feed2imap-go-c08aff21cd67cc27926a4cb1ca72ffe67e015ebf.tar.gz feed2imap-go-c08aff21cd67cc27926a4cb1ca72ffe67e015ebf.tar.bz2 feed2imap-go-c08aff21cd67cc27926a4cb1ca72ffe67e015ebf.zip |
Started caching
Diffstat (limited to '')
-rw-r--r-- | main.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -7,6 +7,7 @@ import ( "os" "sync" + "github.com/Necoro/feed2imap-go/internal/cache" "github.com/Necoro/feed2imap-go/internal/config" "github.com/Necoro/feed2imap-go/internal/feed" "github.com/Necoro/feed2imap-go/internal/imap" @@ -15,6 +16,7 @@ import ( ) var cfgFile = flag.String("f", "config.yml", "configuration file") +var cacheFile = flag.String("c", "feed.cache", "cache file") var verbose = flag.Bool("v", false, "enable verbose output") func processFeed(feed *feed.Feed, cfg *config.Config, client *imap.Client, wg *sync.WaitGroup) { @@ -64,6 +66,11 @@ func run() error { return fmt.Errorf("No successfull feed fetch.") } + feedCache, err := cache.Read(*cacheFile) + if err != nil { + return err + } + imapUrl, err := url.Parse(cfg.Target) if err != nil { return fmt.Errorf("parsing 'target': %w", err) @@ -83,6 +90,10 @@ func run() error { } wg.Wait() + if err = cache.Store(*cacheFile, feedCache); err != nil { + return err + } + return nil } |