BazaarDownloadStrategy: handle corrupt checkouts

This commit is contained in:
Jack Nagel 2013-09-28 18:28:41 -05:00
parent 06d2aa11ee
commit a380265e90

View File

@ -695,16 +695,29 @@ 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://], '')
if @clone.exist? && repo_valid?
puts "Updating #{@clone}"
@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
else
puts "Updating #{@clone}"
Dir.chdir(@clone) { safe_system bzrpath, 'update' }
end
end
def stage