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
|
private
|
||||||
|
|
||||||
def fetch_fetchable f
|
def fetch_fetchable f
|
||||||
f.cached_download.rmtree if already_fetched?(f) && ARGV.force?
|
f.clear_cache if ARGV.force?
|
||||||
download = f.fetch
|
download = f.fetch
|
||||||
|
|
||||||
return unless download.file?
|
return unless download.file?
|
||||||
|
|||||||
@ -35,6 +35,7 @@ class AbstractDownloadStrategy
|
|||||||
def fetch; end
|
def fetch; end
|
||||||
def stage; end
|
def stage; end
|
||||||
def cached_location; end
|
def cached_location; end
|
||||||
|
def clear_cache; end
|
||||||
end
|
end
|
||||||
|
|
||||||
class VCSDownloadStrategy < AbstractDownloadStrategy
|
class VCSDownloadStrategy < AbstractDownloadStrategy
|
||||||
@ -63,6 +64,10 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
def cached_location
|
def cached_location
|
||||||
@clone
|
@clone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_cache
|
||||||
|
cached_location.rmtree if cached_location.exist?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CurlDownloadStrategy < AbstractDownloadStrategy
|
class CurlDownloadStrategy < AbstractDownloadStrategy
|
||||||
@ -86,6 +91,10 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
|||||||
tarball_path
|
tarball_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_cache
|
||||||
|
[cached_location, temporary_path].each { |f| f.unlink if f.exist? }
|
||||||
|
end
|
||||||
|
|
||||||
def downloaded_size
|
def downloaded_size
|
||||||
temporary_path.size? or 0
|
temporary_path.size? or 0
|
||||||
end
|
end
|
||||||
|
|||||||
@ -192,6 +192,10 @@ class Formula
|
|||||||
downloader.cached_location
|
downloader.cached_location
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_cache
|
||||||
|
downloader.clear_cache
|
||||||
|
end
|
||||||
|
|
||||||
# Can be overridden to selectively disable bottles from formulae.
|
# Can be overridden to selectively disable bottles from formulae.
|
||||||
# Defaults to true so overridden version does not have to check if bottles
|
# Defaults to true so overridden version does not have to check if bottles
|
||||||
# are supported.
|
# are supported.
|
||||||
|
|||||||
@ -43,6 +43,10 @@ class Resource
|
|||||||
downloader.cached_location
|
downloader.cached_location
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_cache
|
||||||
|
downloader.clear_cache
|
||||||
|
end
|
||||||
|
|
||||||
# Fetch, verify, and unpack the resource
|
# Fetch, verify, and unpack the resource
|
||||||
def stage(target=nil, &block)
|
def stage(target=nil, &block)
|
||||||
verify_download_integrity(fetch)
|
verify_download_integrity(fetch)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user