Merge pull request #12301 from MikeMcQuaid/retry_github_packages_manifest
Retry GitHub Packages manifest download if invalid.
This commit is contained in:
		
						commit
						1145967a22
					
				@ -323,6 +323,8 @@ class Bottle
 | 
			
		||||
    @resource.version = formula.pkg_version
 | 
			
		||||
    @resource.checksum = tag_spec.checksum
 | 
			
		||||
 | 
			
		||||
    @fetch_tab_retried = false
 | 
			
		||||
 | 
			
		||||
    root_url(spec.root_url, spec.root_url_specs)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -338,6 +340,7 @@ class Bottle
 | 
			
		||||
  def clear_cache
 | 
			
		||||
    @resource.clear_cache
 | 
			
		||||
    github_packages_manifest_resource&.clear_cache
 | 
			
		||||
    @fetch_tab_retried = false
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def compatible_locations?
 | 
			
		||||
@ -360,23 +363,31 @@ class Bottle
 | 
			
		||||
    github_packages_manifest_resource.fetch(verify_download_integrity: false)
 | 
			
		||||
 | 
			
		||||
    begin
 | 
			
		||||
      JSON.parse(github_packages_manifest_resource.cached_download.read)
 | 
			
		||||
    rescue JSON::ParserError
 | 
			
		||||
      raise DownloadError.new(
 | 
			
		||||
        github_packages_manifest_resource,
 | 
			
		||||
        RuntimeError.new("The downloaded GitHub Packages manifest was corrupted or modified (it is not valid JSON):"\
 | 
			
		||||
                         "\n#{github_packages_manifest_resource.cached_download}"),
 | 
			
		||||
      )
 | 
			
		||||
      github_packages_manifest_resource_tab(github_packages_manifest_resource)
 | 
			
		||||
    rescue RuntimeError => e
 | 
			
		||||
      raise DownloadError.new(github_packages_manifest_resource, e)
 | 
			
		||||
    end
 | 
			
		||||
  rescue DownloadError
 | 
			
		||||
    raise unless fallback_on_error
 | 
			
		||||
 | 
			
		||||
    retry
 | 
			
		||||
  rescue ArgumentError
 | 
			
		||||
    raise if @fetch_tab_retried
 | 
			
		||||
 | 
			
		||||
    @fetch_tab_retried = true
 | 
			
		||||
    github_packages_manifest_resource.clear_cache
 | 
			
		||||
    retry
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def tab_attributes
 | 
			
		||||
    return {} unless github_packages_manifest_resource&.downloaded?
 | 
			
		||||
 | 
			
		||||
    github_packages_manifest_resource_tab(github_packages_manifest_resource)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def github_packages_manifest_resource_tab(github_packages_manifest_resource)
 | 
			
		||||
    manifest_json = github_packages_manifest_resource.cached_download.read
 | 
			
		||||
 | 
			
		||||
    json = begin
 | 
			
		||||
@ -411,8 +422,6 @@ class Bottle
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def github_packages_manifest_resource
 | 
			
		||||
    return if @resource.download_strategy != CurlGitHubPackagesDownloadStrategy
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user