From 59f4a711cd0bc04e005a7b4d7eef317ea8169310 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 3 Apr 2021 05:17:08 +0200 Subject: [PATCH] Deprecate `_fetch` without `timeout` option. --- Library/Homebrew/compat/early.rb | 4 ++++ .../compat/{ => early}/download_strategy.rb | 0 .../Homebrew/{compat.rb => compat/late.rb} | 2 +- .../Homebrew/compat/late/download_strategy.rb | 20 +++++++++++++++++++ Library/Homebrew/global.rb | 4 +++- Library/Homebrew/system_command.rb | 1 + 6 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 Library/Homebrew/compat/early.rb rename Library/Homebrew/compat/{ => early}/download_strategy.rb (100%) rename Library/Homebrew/{compat.rb => compat/late.rb} (52%) create mode 100644 Library/Homebrew/compat/late/download_strategy.rb diff --git a/Library/Homebrew/compat/early.rb b/Library/Homebrew/compat/early.rb new file mode 100644 index 0000000000..4f0d4338c8 --- /dev/null +++ b/Library/Homebrew/compat/early.rb @@ -0,0 +1,4 @@ +# typed: strict +# frozen_string_literal: true + +require_relative "early/download_strategy" diff --git a/Library/Homebrew/compat/download_strategy.rb b/Library/Homebrew/compat/early/download_strategy.rb similarity index 100% rename from Library/Homebrew/compat/download_strategy.rb rename to Library/Homebrew/compat/early/download_strategy.rb diff --git a/Library/Homebrew/compat.rb b/Library/Homebrew/compat/late.rb similarity index 52% rename from Library/Homebrew/compat.rb rename to Library/Homebrew/compat/late.rb index a4e5ff6ae5..948b451f06 100644 --- a/Library/Homebrew/compat.rb +++ b/Library/Homebrew/compat/late.rb @@ -1,4 +1,4 @@ # typed: strict # frozen_string_literal: true -require "compat/download_strategy" +require_relative "late/download_strategy" diff --git a/Library/Homebrew/compat/late/download_strategy.rb b/Library/Homebrew/compat/late/download_strategy.rb new file mode 100644 index 0000000000..9f66c02d16 --- /dev/null +++ b/Library/Homebrew/compat/late/download_strategy.rb @@ -0,0 +1,20 @@ +# typed: false +# frozen_string_literal: true + +class CurlDownloadStrategy + module Compat + def _fetch(*args, **options) + unless options.key?(:timeout) + odeprecated "#{self.class}#_fetch" + options[:timeout] = nil + end + super(*args, **options) + end + end + + prepend Compat +end + +class CurlPostDownloadStrategy + prepend Compat +end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index ffb5024b1b..d668dac471 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -75,7 +75,7 @@ HOMEBREW_BOTTLES_EXTNAME_REGEX = /\.([a-z0-9_]+)\.bottle\.(?:(\d+)\.)?tar\.gz$/. require "utils/sorbet" require "env_config" -require "compat" unless Homebrew::EnvConfig.no_compat? +require "compat/early" unless Homebrew::EnvConfig.no_compat? require "os" require "messages" @@ -154,3 +154,5 @@ require "tap_constants" # Enables `patchelf.rb` write support. HOMEBREW_PATCHELF_RB_WRITE = ENV["HOMEBREW_NO_PATCHELF_RB_WRITE"].blank?.freeze + +require "compat/late" unless Homebrew::EnvConfig.no_compat? diff --git a/Library/Homebrew/system_command.rb b/Library/Homebrew/system_command.rb index ea44cf25db..05371490c1 100644 --- a/Library/Homebrew/system_command.rb +++ b/Library/Homebrew/system_command.rb @@ -220,6 +220,7 @@ class SystemCommand loop do readable_sources, = IO.select(sources_remaining, [], [], end_time&.remaining!) raise Timeout::Error if readable_sources.nil? + readable_sources = T.must(readable_sources) break if readable_sources.empty?