Use Downloadable API in FromBottleLoader.
This commit is contained in:
parent
0a7b61a0a9
commit
643fa83a28
@ -592,21 +592,21 @@ module Formulary
|
|||||||
def self.try_new(ref, from: T.unsafe(nil), warn: false)
|
def self.try_new(ref, from: T.unsafe(nil), warn: false)
|
||||||
ref = ref.to_s
|
ref = ref.to_s
|
||||||
|
|
||||||
new(ref) if HOMEBREW_BOTTLES_EXTNAME_REGEX.match?(ref)
|
new(ref, warn:) if HOMEBREW_BOTTLES_EXTNAME_REGEX.match?(ref)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(bottle_name)
|
def initialize(bottle_name, warn: false)
|
||||||
case bottle_name
|
case bottle_name
|
||||||
when URL_START_REGEX
|
when URL_START_REGEX
|
||||||
# The name of the formula is found between the last slash and the last hyphen.
|
# The name of the formula is found between the last slash and the last hyphen.
|
||||||
formula_name = File.basename(bottle_name)[/(.+)-/, 1]
|
formula_name = File.basename(bottle_name)[/(.+)-/, 1]
|
||||||
resource = Resource.new(formula_name) { url bottle_name }
|
resource = Resource.new(formula_name) { url bottle_name, bottle: true }
|
||||||
resource.specs[:bottle] = true
|
if resource.downloaded?
|
||||||
downloader = resource.downloader
|
ohai "Pouring the cached bottle" unless warn
|
||||||
cached = downloader.cached_location.exist?
|
else
|
||||||
downloader.fetch
|
resource.fetch
|
||||||
ohai "Pouring the cached bottle" if cached
|
end
|
||||||
@bottle_filename = downloader.cached_location
|
@bottle_filename = resource.cached_download
|
||||||
else
|
else
|
||||||
@bottle_filename = Pathname(bottle_name).realpath
|
@bottle_filename = Pathname(bottle_name).realpath
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user