From 04a4897b69f9a10bdea27fb1133bcab71c40b687 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Fri, 1 May 2020 21:39:37 +0200 Subject: Config option 'max-failures' --- internal/feed/cache.go | 2 +- internal/feed/cache_v1.go | 4 ++-- internal/feed/parse.go | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/feed/cache.go b/internal/feed/cache.go index 0b2f905..f1dfb77 100644 --- a/internal/feed/cache.go +++ b/internal/feed/cache.go @@ -25,7 +25,7 @@ type Cache interface { type CachedFeed interface { Checked(withFailure bool) - Failures() uint + Failures() int Last() time.Time filterItems(items []feeditem, ignoreHash bool, alwaysNew bool) []feeditem Commit() diff --git a/internal/feed/cache_v1.go b/internal/feed/cache_v1.go index 37a4773..5f8c8f4 100644 --- a/internal/feed/cache_v1.go +++ b/internal/feed/cache_v1.go @@ -25,7 +25,7 @@ type v1Cache struct { type cachedFeed struct { LastCheck time.Time currentCheck time.Time - NumFailures uint // can't be named `Failures` b/c it'll collide with the interface + NumFailures int // can't be named `Failures` b/c it'll collide with the interface Items []cachedItem newItems []cachedItem } @@ -67,7 +67,7 @@ func (cf *cachedFeed) Commit() { cf.LastCheck = cf.currentCheck } -func (cf *cachedFeed) Failures() uint { +func (cf *cachedFeed) Failures() int { return cf.NumFailures } diff --git a/internal/feed/parse.go b/internal/feed/parse.go index fe3374a..1ce6cda 100644 --- a/internal/feed/parse.go +++ b/internal/feed/parse.go @@ -65,6 +65,10 @@ func handleFeed(feed *Feed) { err := parseFeed(feed) if err != nil { - log.Error(err) + if feed.cached.Failures() >= feed.Global.MaxFailures { + log.Error(err) + } else { + log.Print(err) + } } } -- cgit v1.2.3-70-g09d2