No spurious error due to Interrupt during curl

Only delete the file that is downloaded if an error occurs while downloading it.
This commit is contained in:
Max Howell 2009-09-05 20:47:15 +01:00
parent 680e201923
commit de620e4396
2 changed files with 7 additions and 7 deletions

View File

@ -1,9 +1,7 @@
# This script contains bash completions for brew. # This script contains bash completions for brew.
#
# To use, edit your .bashrc and add the line: # To use, edit your .bashrc and add the line:
# source `brew --prefix`/Library/Contributions/brew_bash_completion.sh # source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
#
# Assuming you have brew installed in /usr/local, then you'll want:
# source /usr/local/Library/Contributions/brew_bash_completion.sh
_brew_to_completion() _brew_to_completion()
{ {

View File

@ -37,14 +37,16 @@ class HttpDownloadStrategy <AbstractDownloadStrategy
@dl=HOMEBREW_CACHE+File.basename(@url) @dl=HOMEBREW_CACHE+File.basename(@url)
end end
unless @dl.exist? unless @dl.exist?
curl @url, '-o', @dl begin
curl @url, '-o', @dl
rescue
@dl.unlink
raise
end
else else
puts "File already downloaded and cached" puts "File already downloaded and cached"
end end
return @dl # thus performs checksum verification return @dl # thus performs checksum verification
rescue Exception
@dl.unlink
raise "There was an error downloading the file:\n#{@url}"
end end
def stage def stage
case `file -b #{@dl}` case `file -b #{@dl}`