mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Reorganize resource download methods
This commit is contained in:
parent
978f0887cb
commit
e3a3a0c320
@ -30,10 +30,21 @@ class Resource
|
|||||||
end
|
end
|
||||||
|
|
||||||
def downloader
|
def downloader
|
||||||
download_name = name == :default ? owner.name : "#{owner.name}--#{name}"
|
|
||||||
@downloader ||= download_strategy.new(download_name, self)
|
@downloader ||= download_strategy.new(download_name, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def download_name
|
||||||
|
name == :default ? owner.name : "#{owner.name}--#{name}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def download_strategy
|
||||||
|
@download_strategy ||= DownloadStrategyDetector.detect(url, using)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cached_download
|
||||||
|
downloader.cached_location
|
||||||
|
end
|
||||||
|
|
||||||
# Download the resource
|
# Download the resource
|
||||||
# If a target is given, unpack there; else unpack to a temp folder
|
# If a target is given, unpack there; else unpack to a temp folder
|
||||||
# If block is given, yield to that block
|
# If block is given, yield to that block
|
||||||
@ -51,14 +62,6 @@ class Resource
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_strategy
|
|
||||||
@download_strategy ||= DownloadStrategyDetector.detect(url, using)
|
|
||||||
end
|
|
||||||
|
|
||||||
def cached_download
|
|
||||||
downloader.cached_location
|
|
||||||
end
|
|
||||||
|
|
||||||
# For brew-fetch and others.
|
# For brew-fetch and others.
|
||||||
def fetch
|
def fetch
|
||||||
# Ensure the cache exists
|
# Ensure the cache exists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user