diff options
| -rw-r--r-- | Library/Homebrew/cmd/fetch.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/resource.rb | 4 | 
4 files changed, 18 insertions, 1 deletions
| diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index 8af5ff7ca..c968e6003 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -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? diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index d17f39ce6..72b4b8f03 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index efdc65416..fd1884e4f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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. diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 8b3ce4c33..b72d55254 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -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) | 
