mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 17:22:35 +00:00
33 lines
537 B
Ruby
33 lines
537 B
Ruby
class W3DHub
|
|
class Cache
|
|
def self.path(uri)
|
|
ext = File.basename(uri).split(".").last
|
|
|
|
"#{CACHE_PATH}/#{Digest::SHA2.hexdigest(uri)}.#{ext}"
|
|
end
|
|
|
|
def self.fetch(uri)
|
|
path = path(uri)
|
|
|
|
if File.exist?(path)
|
|
path
|
|
else
|
|
response = Excon.get(uri)
|
|
|
|
if response.status == 200
|
|
File.open(path, "wb") do |f|
|
|
f.write(response.body)
|
|
end
|
|
|
|
path
|
|
end
|
|
|
|
false
|
|
end
|
|
end
|
|
|
|
def self.fetch_package(*args)
|
|
end
|
|
end
|
|
end
|