Skip to content

Commit ebd4ad6

Browse files
committed
download_queue: fix patch handling.
These were being downloaded twice simultaneously which causes a locking race condition. While we're here, also improve the output of bottle manifests and patches in the download queue.
1 parent d746234 commit ebd4ad6

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

Library/Homebrew/resource.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ def files(*files)
137137
verify_download_integrity: T::Boolean,
138138
timeout: T.nilable(T.any(Integer, Float)),
139139
quiet: T::Boolean,
140+
skip_patches: T::Boolean,
140141
).returns(Pathname)
141142
}
142-
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
143-
fetch_patches
143+
def fetch(verify_download_integrity: true, timeout: nil, quiet: false, skip_patches: false)
144+
fetch_patches unless skip_patches
144145

145-
super
146+
super(verify_download_integrity:, timeout:, quiet:)
146147
end
147148

148149
# {Livecheck} can be used to check for newer versions of the software.
@@ -345,6 +346,9 @@ def installed_size
345346
sig { override.returns(String) }
346347
def download_type = "Bottle Manifest"
347348

349+
sig { override.returns(String) }
350+
def name = bottle.name
351+
348352
private
349353

350354
def manifest_annotations
@@ -400,6 +404,15 @@ def directory(val = nil)
400404

401405
sig { override.returns(String) }
402406
def download_type = "Patch"
407+
408+
sig { override.returns(String) }
409+
def name
410+
if (url = self.url)
411+
url.to_s.split("/").last
412+
else
413+
super
414+
end
415+
end
403416
end
404417
end
405418

Library/Homebrew/retryable_download.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
6060

6161
already_downloaded = downloadable.downloaded?
6262

63-
download = downloadable.fetch(verify_download_integrity: false, timeout:, quiet:)
63+
download = if downloadable.is_a?(Resource) && (resource = T.cast(downloadable, Resource))
64+
resource.fetch(verify_download_integrity: false, timeout:, quiet:, skip_patches: true)
65+
else
66+
downloadable.fetch(verify_download_integrity: false, timeout:, quiet:)
67+
end
6468

6569
return download unless download.file?
6670

0 commit comments

Comments
 (0)