@@ -19,14 +19,13 @@ def checksum = downloadable.checksum
1919 sig { override . returns ( T ::Array [ String ] ) }
2020 def mirrors = downloadable . mirrors
2121
22- sig { params ( downloadable : Downloadable , tries : Integer , pour : T :: Boolean ) . void }
23- def initialize ( downloadable , tries :, pour : false )
22+ sig { params ( downloadable : Downloadable , tries : Integer ) . void }
23+ def initialize ( downloadable , tries :)
2424 super ( )
2525
2626 @downloadable = downloadable
2727 @try = T . let ( 0 , Integer )
2828 @tries = tries
29- @pour = pour
3029 end
3130
3231 sig { override . returns ( String ) }
@@ -58,8 +57,6 @@ def downloader = downloadable.downloader
5857 ) . returns ( Pathname )
5958 }
6059 def fetch ( verify_download_integrity : true , timeout : nil , quiet : false )
61- bottle_tmp_keg = nil
62-
6360 @try += 1
6461
6562 downloadable . downloading!
@@ -84,41 +81,12 @@ def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
8481 json_download = downloadable . is_a? ( API ::JSONDownload )
8582 downloadable . verify_download_integrity ( download ) if verify_download_integrity && !json_download
8683
87- if pour && downloadable . is_a? ( Bottle )
88- downloadable . extracting!
89-
90- HOMEBREW_TEMP_CELLAR . mkpath
91-
92- bottle_filename = T . cast ( downloadable , Bottle ) . filename
93- bottle_tmp_keg = HOMEBREW_TEMP_CELLAR /bottle_filename . name /bottle_filename . version . to_s
94- bottle_poured_file = Pathname ( "#{ bottle_tmp_keg } .poured" )
95-
96- unless bottle_poured_file . exist?
97- FileUtils . rm ( bottle_poured_file ) if bottle_poured_file . symlink?
98- FileUtils . rm_r ( bottle_tmp_keg ) if bottle_tmp_keg . directory?
99-
100- UnpackStrategy . detect ( download , prioritize_extension : true )
101- . extract_nestedly ( to : HOMEBREW_TEMP_CELLAR )
102-
103- # Create a separate file to mark a completed extraction. This avoids
104- # a potential race condition if a user interrupts the install.
105- # We use a symlink to easily check that both this extra status file
106- # and the real extracted directory exist via `Pathname#exist?`.
107- FileUtils . ln_s ( bottle_tmp_keg , bottle_poured_file )
108- end
109-
110- downloadable . downloaded!
111- elsif json_download
112- FileUtils . touch ( download , mtime : Time . now )
113- end
84+ FileUtils . touch ( download , mtime : Time . now ) if json_download
11485
11586 download
11687 rescue DownloadError , ChecksumMismatchError , Resource ::BottleManifest ::Error => e
11788 tries_remaining = @tries - @try
118- if tries_remaining . zero?
119- cleanup_partial_installation_on_error! ( bottle_tmp_keg )
120- raise
121- end
89+ raise if tries_remaining . zero?
12290
12391 wait = 2 ** @try
12492 unless quiet
@@ -132,10 +100,6 @@ def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
132100 # fully-downloaded file is known-bad (checksum or manifest mismatch).
133101 downloadable . clear_cache unless e . is_a? ( DownloadError )
134102 retry
135- # Catch any other types of exceptions as they leave us with partial installations.
136- rescue Exception # rubocop:disable Lint/RescueException
137- cleanup_partial_installation_on_error! ( bottle_tmp_keg )
138- raise
139103 end
140104
141105 sig { override . params ( filename : Pathname ) . void }
@@ -145,19 +109,5 @@ def verify_download_integrity(filename) = downloadable.verify_download_integrity
145109
146110 sig { returns ( Downloadable ) }
147111 attr_reader :downloadable
148-
149- sig { returns ( T ::Boolean ) }
150- attr_reader :pour
151-
152- sig { params ( path : T . nilable ( Pathname ) ) . void }
153- def cleanup_partial_installation_on_error! ( path )
154- return if path . nil?
155- return unless path . directory?
156-
157- ignore_interrupts do
158- FileUtils . rm_r ( path )
159- path . parent . rmdir_if_possible
160- end
161- end
162112 end
163113end
0 commit comments