From c1ba9975b8349c9eff2bf55bd4319c0bbe45dc73 Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Mon, 13 Apr 2020 19:59:22 +1000 Subject: [PATCH] pr-pull: fetch artifacts with no-resume strategy --- Library/Homebrew/dev-cmd/pr-pull.rb | 12 +++++++++++- Library/Homebrew/utils/github.rb | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/pr-pull.rb b/Library/Homebrew/dev-cmd/pr-pull.rb index bf2215b273..fe432c56ca 100644 --- a/Library/Homebrew/dev-cmd/pr-pull.rb +++ b/Library/Homebrew/dev-cmd/pr-pull.rb @@ -5,6 +5,14 @@ require "utils/github" require "tmpdir" require "bintray" +class CurlNoResumeDownloadStrategy < CurlDownloadStrategy + private + + def _fetch(url:, resolved_url:) + curl("--location", "--remote-time", "--create-dirs", "--output", temporary_path, resolved_url) + end +end + module Homebrew module_function @@ -192,7 +200,9 @@ module Homebrew if Homebrew.args.dry_run? puts "Upload bottles described by these JSON files to Bintray:\n #{Dir["*.json"].join("\n ")}" else - bintray.upload_bottle_json Dir["*.json"], publish_package: !args.no_publish? + bintray.upload_bottle_json Dir["*.json"], + publish_package: !args.no_publish?, + strategy: CurlNoResumeDownloadStrategy end end end diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index acce9e5bde..33d60a8cb3 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -435,7 +435,8 @@ module GitHub scopes: CREATE_ISSUE_FORK_OR_PR_SCOPES) end - def fetch_artifact(user, repo, pr, dir, workflow_id: "tests.yml", artifact_name: "bottles") + def fetch_artifact(user, repo, pr, dir, + workflow_id: "tests.yml", artifact_name: "bottles", strategy: CurlDownloadStrategy) scopes = CREATE_ISSUE_FORK_OR_PR_SCOPES base_url = "#{API_URL}/repos/#{user}/#{repo}" pr_payload = open_api("#{base_url}/pulls/#{pr}", scopes: scopes) @@ -496,7 +497,7 @@ module GitHub FileUtils.chdir dir do curl_args[:cache] = Pathname.new(dir) curl_args[:secrets] = [token] - downloader = CurlDownloadStrategy.new(artifact_url, "artifact", pr, **curl_args) + downloader = strategy.new(artifact_url, "artifact", pr, **curl_args) downloader.fetch downloader.stage end