aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/download_strategy.rb
diff options
context:
space:
mode:
authorJack Nagel2013-09-28 18:28:41 -0500
committerJack Nagel2013-09-28 18:38:32 -0500
commitb04caba92301c72258b12e1fb4ebd1c418c8dd55 (patch)
tree4911a8bed740fe1061e723398291c069339585e7 /Library/Homebrew/download_strategy.rb
parent017385b35d6bffe28cc42a4d65fe36d949d733d2 (diff)
downloadhomebrew-b04caba92301c72258b12e1fb4ebd1c418c8dd55.tar.bz2
BazaarDownloadStrategy: handle corrupt checkouts
Diffstat (limited to 'Library/Homebrew/download_strategy.rb')
-rw-r--r--Library/Homebrew/download_strategy.rb25
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