fetch: clear partial downloads when --force is given

Fixes Homebrew/homebrew#23764.
This commit is contained in:
Jack Nagel 2013-10-31 14:28:49 -05:00
parent 71f0ad069d
commit d35e465671
4 changed files with 18 additions and 1 deletions

View File

@ -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?

View 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

View File

@ -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.

View File

@ -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)