Add DownloadError to catch a broader range of resource download errors.
Adding a broader exception class allows for errors raised in Resource.fetch to be caught in upgrade and prevent the process from being killed when a download fails. This should resolve issue 18364. Fixes Homebrew/homebrew#18364. Closes Homebrew/homebrew#26618. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
ca0eff67fa
commit
d63ef14794
@ -92,6 +92,8 @@ module Homebrew extend self
|
|||||||
e.dump
|
e.dump
|
||||||
puts
|
puts
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
|
rescue DownloadError => e
|
||||||
|
ofail e
|
||||||
ensure
|
ensure
|
||||||
# restore previous installation state if build failed
|
# restore previous installation state if build failed
|
||||||
outdated_keg.link if outdated_keg and not f.installed? rescue nil
|
outdated_keg.link if outdated_keg and not f.installed? rescue nil
|
||||||
|
|||||||
@ -229,6 +229,13 @@ class CompilerSelectionError < Homebrew::InstallationError
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Raised in Resource.fetch
|
||||||
|
class DownloadError < RuntimeError
|
||||||
|
def initialize(formula)
|
||||||
|
super "Failed to download resource for package: #{formula}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# raised in CurlDownloadStrategy.fetch
|
# raised in CurlDownloadStrategy.fetch
|
||||||
class CurlDownloadStrategyError < RuntimeError; end
|
class CurlDownloadStrategyError < RuntimeError; end
|
||||||
|
|
||||||
|
|||||||
@ -76,10 +76,14 @@ class Resource
|
|||||||
|
|
||||||
# For brew-fetch and others.
|
# For brew-fetch and others.
|
||||||
def fetch
|
def fetch
|
||||||
# Ensure the cache exists
|
begin
|
||||||
HOMEBREW_CACHE.mkpath
|
# Ensure the cache exists
|
||||||
downloader.fetch
|
HOMEBREW_CACHE.mkpath
|
||||||
cached_download
|
downloader.fetch
|
||||||
|
cached_download
|
||||||
|
rescue ErrorDuringExecution, CurlDownloadStrategyError => e
|
||||||
|
raise DownloadError.new(downloader.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_download_integrity fn
|
def verify_download_integrity fn
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user