@@ -179,30 +179,29 @@ def download_url
179179 # download_file!(download_url, downloaded_file, options)
180180 # end
181181 def download
182+ log . warn ( log_key ) { source [ :warning ] } if source . key? ( :warning )
183+
182184 options = { }
183185
186+ if source [ :unsafe ]
187+ log . warn ( log_key ) { "Permitting unsafe redirects!" }
188+ options [ :allow_unsafe_redirects ] = true
189+ end
190+
191+ # Set the cookie if one was given
184192 options [ "Cookie" ] = source [ :cookie ] if source [ :cookie ]
185193 options [ "Authorization" ] = source [ :authorization ] if source [ :authorization ]
186194
187195 begin
188- # Attempt the original download which tries internal source if configured
189- super
196+ # Attempt download from internal or S3 source URL
197+ download_file! ( download_url , downloaded_file , options )
190198 rescue OpenURI ::HTTPError => e
191- # Check if the error is a 404 from internal source while internal sources are enabled
199+ # If 404 comes from internal source, fallback to external URL
192200 if e . io . status [ 0 ] == "404" && Config . use_internal_sources && source [ :internal ]
193201 log . warn ( log_key ) { "Internal source returned 404 Not Found for #{ name } , falling back to external source URL." }
194-
195- # Temporarily disable internal sources to force external URL usage
196- Config . use_internal_sources ( false )
197- begin
198- # Retry download explicitly from external source URL
199- download_file! ( source [ :url ] , downloaded_file , options )
200- ensure
201- # Restore the original internal sources config
202- Config . use_internal_sources ( true )
203- end
202+ download_file! ( source [ :url ] , downloaded_file , options )
204203 else
205- # Raise any other HTTP errors as usual
204+ # Re-raise other errors
206205 raise
207206 end
208207 end
0 commit comments