aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-22 22:54:43 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-22 22:54:43 +0100
commit7106d5a6e7585dce5fdd552cca30063dd352dc23 (patch)
tree88a9cb7150f86fcadb8f87e3a6d0892bf68c2251 /main.go
parentfb2aa9b1f04d509c8215c1fa6505a144482c343d (diff)
downloadfeed2imap-go-7106d5a6e7585dce5fdd552cca30063dd352dc23.tar.gz
feed2imap-go-7106d5a6e7585dce5fdd552cca30063dd352dc23.tar.bz2
feed2imap-go-7106d5a6e7585dce5fdd552cca30063dd352dc23.zip
Split cache and feed packages
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/main.go b/main.go
index abc80fa..86a6ddf 100644
--- a/main.go
+++ b/main.go
@@ -5,7 +5,7 @@ import (
"fmt"
"os"
- "github.com/Necoro/feed2imap-go/internal/feed"
+ "github.com/Necoro/feed2imap-go/internal/feed/cache"
"github.com/Necoro/feed2imap-go/internal/imap"
"github.com/Necoro/feed2imap-go/pkg/config"
"github.com/Necoro/feed2imap-go/pkg/log"
@@ -33,7 +33,8 @@ func init() {
flag.BoolVar(&debug, "d", debug, "enable debug output")
}
-func processFeed(feed *feed.Feed, client *imap.Client, dryRun bool) {
+func processFeed(cf cache.CachedFeed, client *imap.Client, dryRun bool) {
+ feed := cf.Feed()
msgs, err := feed.Messages()
if err != nil {
log.Errorf("Processing items of feed %s: %s", feed.Name, err)
@@ -41,7 +42,7 @@ func processFeed(feed *feed.Feed, client *imap.Client, dryRun bool) {
}
if dryRun || len(msgs) == 0 {
- feed.MarkSuccess()
+ cf.Commit()
return
}
@@ -58,7 +59,7 @@ func processFeed(feed *feed.Feed, client *imap.Client, dryRun bool) {
log.Printf("Uploaded %d messages to '%s' @ %s", len(msgs), feed.Name, folder)
- feed.MarkSuccess()
+ cf.Commit()
}
func run() error {
@@ -81,7 +82,7 @@ func run() error {
return err
}
- state, err := feed.NewState(cfg)
+ state, err := cache.NewState(cfg)
if err != nil {
return err
}
@@ -116,9 +117,9 @@ func run() error {
}
if buildCache {
- state.Foreach((*feed.Feed).MarkSuccess)
+ state.Foreach(cache.CachedFeed.Commit)
} else {
- state.ForeachGo(func(f *feed.Feed) {
+ state.ForeachGo(func(f cache.CachedFeed) {
processFeed(f, c, dryRun)
})
}