From 63d20f3f7b02f33475049c12e03569a4f67fe810 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sun, 26 Apr 2020 17:52:55 +0200 Subject: Options: "disable" and "ignore-hash" --- internal/feed/cache.go | 2 +- internal/feed/cache_v1.go | 6 +++--- internal/feed/state.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'internal') diff --git a/internal/feed/cache.go b/internal/feed/cache.go index 2a51cb5..b92bfa7 100644 --- a/internal/feed/cache.go +++ b/internal/feed/cache.go @@ -27,7 +27,7 @@ type CachedFeed interface { Checked(withFailure bool) Failures() uint Last() time.Time - filterItems([]feeditem) []feeditem + filterItems([]feeditem, bool) []feeditem Commit() } diff --git a/internal/feed/cache_v1.go b/internal/feed/cache_v1.go index a8e40ed..fb16027 100644 --- a/internal/feed/cache_v1.go +++ b/internal/feed/cache_v1.go @@ -171,7 +171,7 @@ func (cf *cachedFeed) deleteItem(index int) { cf.Items = cf.Items[:len(cf.Items)-1] } -func (cf *cachedFeed) filterItems(items []feeditem) []feeditem { +func (cf *cachedFeed) filterItems(items []feeditem, ignoreHash bool) []feeditem { if len(items) == 0 { return items } @@ -209,7 +209,7 @@ CACHE_ITEMS: for idx, oldItem := range cf.Items { if oldItem.Guid == ci.Guid { log.Debugf("Guid matches with: %s", oldItem) - if !oldItem.similarTo(&ci, false) { + if !oldItem.similarTo(&ci, ignoreHash) { item.addReason("guid (upd)") app(item, ci, &idx) } else { @@ -227,7 +227,7 @@ CACHE_ITEMS: } for idx, oldItem := range cf.Items { - if oldItem.similarTo(&ci, false) { + if oldItem.similarTo(&ci, ignoreHash) { log.Debugf("Similarity matches, ignoring: %s", oldItem) continue CACHE_ITEMS } diff --git a/internal/feed/state.go b/internal/feed/state.go index 6f284ad..ea9239a 100644 --- a/internal/feed/state.go +++ b/internal/feed/state.go @@ -72,7 +72,7 @@ func filterFeed(feed *Feed) { origLen := len(feed.items) log.Debugf("Filtering %s. Starting with %d items", feed.Name, origLen) - items := feed.cached.filterItems(feed.items) + items := feed.cached.filterItems(feed.items, *feed.Options.IgnHash) feed.items = items newLen := len(feed.items) @@ -112,7 +112,7 @@ func NewState(cfg *config.Config) *State { func (state *State) RemoveUndue() { for name, feed := range state.feeds { - if !feed.NeedsUpdate(feed.cached.Last()) { + if *feed.Options.Disable || !feed.NeedsUpdate(feed.cached.Last()) { delete(state.feeds, name) } } -- cgit v1.2.3-54-g00ecf