simplify fetch_error flow
Jes Olson j3s@c3f.net
Wed, 22 Mar 2023 16:55:42 -0700
2 files changed,
3 insertions(+),
15 deletions(-)
M
reaper/reaper.go
→
reaper/reaper.go
@@ -86,14 +86,9 @@ // 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) { err := f.Update() - var errStr string if err != nil { - // some amount of failures are expected - errStr = err.Error() - } - err = r.db.SetFeedFetchError(f.UpdateURL, errStr) - if err != nil { - fmt.Printf("[err] reaper: set fetch_error %s\n", err) + fmt.Printf("[err] reaper: fetch failure url '%s' %s\n", f.UpdateURL, err) + err = r.db.SetFeedFetchError(f.UpdateURL, err.Error()) } }
M
sqlite/sql.go
→
sqlite/sql.go
@@ -210,14 +210,7 @@
// WriteFeed writes an rss feed to the database for permanent storage // if the given feed already exists, WriteFeed does nothing. func (s *DB) SetFeedFetchError(url string, fetchErr string) error { - storedErr, err := s.GetFeedFetchError(url) - if err != nil { - return err - } - if fetchErr == storedErr { - return nil - } - _, err = s.sql.Exec("UPDATE feed SET fetch_error=? WHERE url=?", fetchErr, url) + _, err := s.sql.Exec("UPDATE feed SET fetch_error=? WHERE url=?", fetchErr, url) return err }