aboutsummaryrefslogtreecommitdiff
path: root/internal/feed
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/feed/cache.go2
-rw-r--r--internal/feed/cache_v1.go4
-rw-r--r--internal/feed/feed.go5
-rw-r--r--internal/feed/state.go8
4 files changed, 18 insertions, 1 deletions
diff --git a/internal/feed/cache.go b/internal/feed/cache.go
index 4a0bfe7..735a7d6 100644
--- a/internal/feed/cache.go
+++ b/internal/feed/cache.go
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"os"
+ "time"
"github.com/Necoro/feed2imap-go/pkg/log"
)
@@ -25,6 +26,7 @@ type Cache interface {
type CachedFeed interface {
Checked(withFailure bool)
Failures() uint
+ Last() time.Time
}
func cacheForVersion(version Version) (Cache, error) {
diff --git a/internal/feed/cache_v1.go b/internal/feed/cache_v1.go
index 3d46084..1c53239 100644
--- a/internal/feed/cache_v1.go
+++ b/internal/feed/cache_v1.go
@@ -51,6 +51,10 @@ func (cf *cachedFeed) Failures() uint {
return cf.NumFailures
}
+func (cf *cachedFeed) Last() time.Time {
+ return cf.LastCheck
+}
+
func (cache *v1Cache) Version() Version {
return v1Version
}
diff --git a/internal/feed/feed.go b/internal/feed/feed.go
index d087d3a..4ee2875 100644
--- a/internal/feed/feed.go
+++ b/internal/feed/feed.go
@@ -34,7 +34,10 @@ func (feed *Feed) descriptor() feedDescriptor {
}
func (feed *Feed) NeedsUpdate(updateTime time.Time) bool {
- if !updateTime.IsZero() && int(time.Since(updateTime).Hours()) >= *feed.MinFreq {
+ if *feed.MinFreq == 0 { // shortcut
+ return true
+ }
+ if !updateTime.IsZero() && int(time.Since(updateTime).Hours()) < *feed.MinFreq {
log.Printf("Feed '%s' does not need updating, skipping.", feed.Name)
return false
}
diff --git a/internal/feed/state.go b/internal/feed/state.go
index 9a6f836..8efef5e 100644
--- a/internal/feed/state.go
+++ b/internal/feed/state.go
@@ -74,3 +74,11 @@ func NewState(cfg *config.Config) *State {
return &state
}
+
+func (state *State) RemoveUndue() {
+ for name, feed := range state.feeds {
+ if !feed.NeedsUpdate(feed.cached.Last()) {
+ delete(state.feeds, name)
+ }
+ }
+}
t/portato/gui/gui_helper.py?h=v0.13.1&id=11739be69a3f4368e63c469bc0a8f606bb2cbbec&follow=1'> r669@Devoty: necoro | 2008-01-18 22:49:33 +0100Necoro1-6/+6 2008-01-18 r664@Devoty: necoro | 2008-01-18 21:40:29 +0100Necoro5-26/+181 2008-01-18 r661@Devoty: necoro | 2008-01-18 14:16:59 +0100Necoro8-211/+293 2008-01-18 r655@Devoty: necoro | 2008-01-18 03:04:53 +0100Necoro1-1/+1 2008-01-18 r651@Devoty: necoro | 2008-01-18 02:41:51 +0100Necoro3-393/+513 2008-01-18 r643@Devoty: necoro | 2008-01-16 18:55:49 +0100Necoro14-249/+525 2008-01-14 r634@Devoty: necoro | 2008-01-14 23:48:24 +0100Necoro3-1/+4 2008-01-14 r632@Devoty: necoro | 2008-01-14 23:44:52 +0100Necoro3-175/+181 2008-01-14(no commit message)Necoro10-758/+1014 2008-01-14 r621@Devoty: necoro | 2008-01-14 20:21:40 +0100Necoro2-21/+61 2008-01-14 r618@Devoty: necoro | 2008-01-14 20:19:05 +0100Necoro2-35/+57 2008-01-14 r617@Devoty: necoro | 2008-01-14 19:12:59 +0100Necoro2-10/+10 2008-01-14 r609@Devoty: necoro | 2008-01-14 17:04:38 +0100Necoro9-394/+477 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108