diff options
| author | Jack Nagel | 2013-09-28 18:28:41 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-09-28 18:38:32 -0500 |
| commit | a380265e90e36a6a9e60123f300bdc4094318b98 (patch) | |
| tree | b08fe478ef847b48d97dd4b4e6e013292232c95b /Library | |
| parent | 06d2aa11ee6c201cdd45f29f898dffcec318f5a3 (diff) | |
| download | brew-a380265e90e36a6a9e60123f300bdc4094318b98.tar.bz2 | |
BazaarDownloadStrategy: handle corrupt checkouts
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 4cc59daa6..417aee51a 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -695,18 +695,31 @@ class BazaarDownloadStrategy < AbstractDownloadStrategy ].find { |p| File.executable? p } end + def repo_valid? + @clone.join(".bzr").directory? + end + def fetch ohai "Cloning #{@url}" - unless @clone.exist? - url=@url.sub(%r[^bzr://], '') - # 'lightweight' means history-less - safe_system bzrpath, 'checkout', '--lightweight', url, @clone - else + + if @clone.exist? && repo_valid? puts "Updating #{@clone}" - Dir.chdir(@clone) { safe_system bzrpath, 'update' } + @clone.cd { safe_system bzrpath, 'update' } + elsif @clone.exist? + puts "Removing invalid bzr repo from cache" + @clone.rmtree + clone_repo + else + clone_repo end end + def clone_repo + url = @url.sub(%r[^bzr://], '') + # 'lightweight' means history-less + safe_system bzrpath, 'checkout', '--lightweight', url, @clone + end + def stage # FIXME: The export command doesn't work on checkouts # See https://bugs.launchpad.net/bzr/+bug/897511 |
