CurlDownloadStrategy: dup mirror list before mutating it
This commit is contained in:
parent
28a20b70fc
commit
284a3716ea
@ -67,9 +67,8 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
class CurlDownloadStrategy < AbstractDownloadStrategy
|
class CurlDownloadStrategy < AbstractDownloadStrategy
|
||||||
def initialize name, resource
|
def mirrors
|
||||||
super
|
@mirrors ||= resource.mirrors.dup
|
||||||
@mirrors = resource.mirrors
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def tarball_path
|
def tarball_path
|
||||||
@ -120,9 +119,9 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
|||||||
puts "Already downloaded: #{tarball_path}"
|
puts "Already downloaded: #{tarball_path}"
|
||||||
end
|
end
|
||||||
rescue CurlDownloadStrategyError
|
rescue CurlDownloadStrategyError
|
||||||
raise if @mirrors.empty?
|
raise if mirrors.empty?
|
||||||
puts "Trying a mirror..."
|
puts "Trying a mirror..."
|
||||||
@url = @mirrors.shift
|
@url = mirrors.shift
|
||||||
retry
|
retry
|
||||||
else
|
else
|
||||||
tarball_path
|
tarball_path
|
||||||
@ -170,7 +169,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
|||||||
private
|
private
|
||||||
|
|
||||||
def curl(*args)
|
def curl(*args)
|
||||||
args << '--connect-timeout' << '5' unless @mirrors.empty?
|
args << '--connect-timeout' << '5' unless mirrors.empty?
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -75,8 +75,7 @@ class ResourceTests < Test::Unit::TestCase
|
|||||||
assert_empty @resource.mirrors
|
assert_empty @resource.mirrors
|
||||||
@resource.mirror('foo')
|
@resource.mirror('foo')
|
||||||
@resource.mirror('bar')
|
@resource.mirror('bar')
|
||||||
assert_equal 'foo', @resource.mirrors.shift
|
assert_equal %w{foo bar}, @resource.mirrors
|
||||||
assert_equal 'bar', @resource.mirrors.shift
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_checksum_setters
|
def test_checksum_setters
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user