only write feedfetcherror if changed
Jes Olson j3s@c3f.net
Mon, 20 Mar 2023 19:41:34 -0700
2 files changed,
18 insertions(+),
1 deletions(-)
M
reaper/reaper.go
→
reaper/reaper.go
@@ -85,8 +85,16 @@
// updateFeed triggers a fetch on the given feed, // and sets a fetch error in the db if there is one. func (r *Reaper) updateFeed(f *rss.Feed) { + var currentErr string err := f.Update() - r.db.SetFeedFetchError(f.UpdateURL, err) + if err != nil { + currentErr = err.Error() + } + + storedErr := r.db.GetFeedFetchError(f.UpdateURL) + if currentErr != storedErr { + r.db.SetFeedFetchError(f.UpdateURL, err) + } } // Have checks whether a given url is represented
M
sqlite/sql.go
→
sqlite/sql.go
@@ -219,3 +219,12 @@ if err != nil {
panic(err) } } + +func (s *DB) GetFeedFetchError(url string) string { + var fetchErr string + err := s.sql.QueryRow(`SELECT fetch_error FROM feed WHERE url=?`, url).Scan(&fetchErr) + if err != nil { + panic(err) + } + return fetchErr +}