Fix concurrent download error for duplicate URLs
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
This commit is contained in:
parent
1cfd8589c5
commit
c3934c8d8b
@ -132,6 +132,26 @@ module Downloadable
|
||||
EOS
|
||||
end
|
||||
|
||||
sig { returns(Integer) }
|
||||
def hash
|
||||
[self.class, cached_download].hash
|
||||
end
|
||||
|
||||
sig { params(other: Object).returns(T::Boolean) }
|
||||
def eql?(other)
|
||||
return false if self.class != other.class
|
||||
|
||||
other = T.cast(other, Downloadable)
|
||||
cached_download == other.cached_download
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def to_s
|
||||
short_cached_download = cached_download.to_s
|
||||
.delete_prefix("#{HOMEBREW_CACHE}/downloads/")
|
||||
"#<#{self.class}: #{short_cached_download}>"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
sig { overridable.returns(String) }
|
||||
|
@ -26,14 +26,4 @@ RSpec.describe Homebrew::Cmd::FetchCmd do
|
||||
expect(HOMEBREW_CACHE/"testball2--0.1.tbz").to be_a_symlink
|
||||
expect(HOMEBREW_CACHE/"testball2--0.1.tbz").to exist
|
||||
end
|
||||
|
||||
it "errors when concurrently downloading to the same destination", :integration_test do
|
||||
# This test will fail if the fetch is not performed concurrently.
|
||||
# N.B. this test relies on how we set up test formulae, see the `integration_test` shared context.
|
||||
setup_test_formula "testball1"
|
||||
setup_test_formula "testball3"
|
||||
|
||||
expect { brew "fetch", "testball1", "testball3", "HOMEBREW_DOWNLOAD_CONCURRENCY" => "2" }.to be_a_failure
|
||||
.and output(/Error:.*process has already locked/).to_stderr
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user