small pixel drawing of a pufferfish vore

simplify fetch_error flow
Jes Olson j3s@c3f.net
Wed, 22 Mar 2023 16:55:42 -0700
commit

06e407f8ff4c385bb5fba84c030e683688386304

parent

a3e64a8fc123d4afbe2677fd7c34804ecfdd90ad

2 files changed, 3 insertions(+), 15 deletions(-)

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