This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new b2ccc48d Check for success before caching the response
b2ccc48d is described below
commit b2ccc48d767c79e64e1e3c6f8ea6deef8a9cd0e8
Author: Sebb <[email protected]>
AuthorDate: Fri May 13 23:02:56 2022 +0100
Check for success before caching the response
---
lib/whimsy/cache.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/whimsy/cache.rb b/lib/whimsy/cache.rb
index 0c80e4a7..a560b203 100644
--- a/lib/whimsy/cache.rb
+++ b/lib/whimsy/cache.rb
@@ -77,8 +77,12 @@ class Cache
end
else
uri, res = fetch(url)
- write_cache(url, res)
- return uri, res.body, data ? 'no last mod/etag' : 'missing'
+ if res.is_a?(Net::HTTPSuccess)
+ write_cache(url, res)
+ return uri, res.body, data ? 'no last mod/etag' : 'missing'
+ else
+ return nil, res, 'error'
+ end
end
end