small pixel drawing of a pufferfish vore

only write feedfetcherror if changed
Jes Olson j3s@c3f.net
Mon, 20 Mar 2023 19:41:34 -0700
commit

ccc2f91587c85d84e2bbfec85a7e40040dc8427f

parent

3ea5fa8adc5b485824cd4b103b930e953a582070

2 files changed, 18 insertions(+), 1 deletions(-)

jump to
M reaper/reaper.goreaper/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.gosqlite/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 +}