Merge pull request #20329 from Homebrew/download_concurrency_auto
env_config: add `auto` option for `download_concurrency`
This commit is contained in:
commit
a947ad6e6d
@ -634,9 +634,16 @@ module Homebrew
|
|||||||
sig { returns(Integer) }
|
sig { returns(Integer) }
|
||||||
def download_concurrency
|
def download_concurrency
|
||||||
# TODO: document this variable when ready to publicly announce it.
|
# TODO: document this variable when ready to publicly announce it.
|
||||||
concurrency = ENV.fetch("HOMEBREW_DOWNLOAD_CONCURRENCY", 1).to_i
|
concurrency = ENV.fetch("HOMEBREW_DOWNLOAD_CONCURRENCY", 1)
|
||||||
concurrency = 1 if concurrency <= 1
|
concurrency = if concurrency == "auto"
|
||||||
concurrency
|
require "os"
|
||||||
|
require "hardware"
|
||||||
|
Hardware::CPU.cores * 2
|
||||||
|
else
|
||||||
|
concurrency.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
[concurrency, 1].max
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
8
Library/Homebrew/env_config.rbi
Normal file
8
Library/Homebrew/env_config.rbi
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# typed: strict
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Homebrew
|
||||||
|
module EnvConfig
|
||||||
|
include Kernel
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user