Added option to force fetch to Cache.fetch, force user profile picture to be fetched on start up or on login

This commit is contained in:
2021-12-26 21:32:54 -06:00
parent e87f14079d
commit 55191f143a
3 changed files with 6 additions and 5 deletions

View File

@@ -7,18 +7,18 @@ class W3DHub
end
# Fetch a generic uri
def self.fetch(internet, uri)
def self.fetch(internet, uri, force_fetch = false)
path = path(uri)
if File.exist?(path)
if !force_fetch && File.exist?(path)
path
else
response = internet.get(uri, [["user-agent", W3DHub::Api::USER_AGENT]])
response = internet.get(uri, W3DHub::Api::DEFAULT_HEADERS)
if response.success?
response.save(path, "wb")
path
return path
end
false