From 527a602ebacf119faba355c37edd90d622e256f8 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Thu, 26 May 2022 23:13:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E5=81=9C=E6=AD=A2=E5=90=8E=E7=BB=AD=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=EF=BC=8C=E6=97=A5=E5=BF=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapter/provider/fetcher.go | 5 ++++- rule/provider/fetcher.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/adapter/provider/fetcher.go b/adapter/provider/fetcher.go index 256670f8..c58d7e4d 100644 --- a/adapter/provider/fetcher.go +++ b/adapter/provider/fetcher.go @@ -59,7 +59,7 @@ func (f *fetcher) Initial() (any, error) { isLocal = true if f.interval != 0 && modTime.Add(f.interval).Before(time.Now()) { defer func() { - log.Infoln("[Provider] %s's proxies not updated for a long time") + log.Infoln("[Provider] %s's proxies not updated for a long time, force refresh", f.Name()) go f.update() }() } @@ -160,11 +160,14 @@ func (f *fetcher) update() (same bool, err error) { elm, same, err := f.Update() if err != nil { log.Warnln("[Provider] %s pull error: %s", f.Name(), err.Error()) + return } if same { log.Debugln("[Provider] %s's proxies doesn't change", f.Name()) + return } + if f.onUpdate != nil { f.onUpdate(elm) } diff --git a/rule/provider/fetcher.go b/rule/provider/fetcher.go index 01b9aaa8..89dfd5db 100644 --- a/rule/provider/fetcher.go +++ b/rule/provider/fetcher.go @@ -58,7 +58,7 @@ func (f *fetcher) Initial() (interface{}, error) { hasLocal = true if f.interval != 0 && modTime.Add(f.interval).Before(time.Now()) { defer func() { - log.Infoln("[Provider] %s's rules not updated for a long time", f.Name()) + log.Infoln("[Provider] %s's rules not updated for a long time, force refresh", f.Name()) go f.update() }() } @@ -186,10 +186,12 @@ func (f *fetcher) update() (same bool, err error) { elm, same, err := f.Update() if err != nil { log.Warnln("[Provider] %s pull error: %s", f.Name(), err.Error()) + return } if same { log.Debugln("[Provider] %s's rules doesn't change", f.Name()) + return } log.Infoln("[Provider] %s's rules update", f.Name())