fetch: clear partial downloads when --force is given
Fixes Homebrew/homebrew#23764.
This commit is contained in:
parent
71f0ad069d
commit
d35e465671
@ -46,7 +46,7 @@ module Homebrew extend self
|
||||
private
|
||||
|
||||
def fetch_fetchable f
|
||||
f.cached_download.rmtree if already_fetched?(f) && ARGV.force?
|
||||
f.clear_cache if ARGV.force?
|
||||
download = f.fetch
|
||||
|
||||
return unless download.file?
|
||||
|
||||
@ -35,6 +35,7 @@ class AbstractDownloadStrategy
|
||||
def fetch; end
|
||||
def stage; end
|
||||
def cached_location; end
|
||||
def clear_cache; end
|
||||
end
|
||||
|
||||
class VCSDownloadStrategy < AbstractDownloadStrategy
|
||||
@ -63,6 +64,10 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
||||
def cached_location
|
||||
@clone
|
||||
end
|
||||
|
||||
def clear_cache
|
||||
cached_location.rmtree if cached_location.exist?
|
||||
end
|
||||
end
|
||||
|
||||
class CurlDownloadStrategy < AbstractDownloadStrategy
|
||||
@ -86,6 +91,10 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
||||
tarball_path
|
||||
end
|
||||
|
||||
def clear_cache
|
||||
[cached_location, temporary_path].each { |f| f.unlink if f.exist? }
|
||||
end
|
||||
|
||||
def downloaded_size
|
||||
temporary_path.size? or 0
|
||||
end
|
||||
|
||||
@ -192,6 +192,10 @@ class Formula
|
||||
downloader.cached_location
|
||||
end
|
||||
|
||||
def clear_cache
|
||||
downloader.clear_cache
|
||||
end
|
||||
|
||||
# Can be overridden to selectively disable bottles from formulae.
|
||||
# Defaults to true so overridden version does not have to check if bottles
|
||||
# are supported.
|
||||
|
||||
@ -43,6 +43,10 @@ class Resource
|
||||
downloader.cached_location
|
||||
end
|
||||
|
||||
def clear_cache
|
||||
downloader.clear_cache
|
||||
end
|
||||
|
||||
# Fetch, verify, and unpack the resource
|
||||
def stage(target=nil, &block)
|
||||
verify_download_integrity(fetch)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user