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