cmd/fetch: rename fetch_failed to fetch_tries.

This makes the code substantially easier to understand. Follow-up to #13807.
This commit is contained in:
Carlo Cabrera 2022-09-06 18:35:34 +08:00
parent ccc235171f
commit 708935d2c8
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -162,17 +162,17 @@ module Homebrew
end
def retry_fetch?(f, args:)
@fetch_failed ||= Hash.new { |h, k| h[k] = 1 }
if args.retry? && (@fetch_failed[f] < FETCH_MAX_TRIES)
wait = 2 ** @fetch_failed[f]
remaining = FETCH_MAX_TRIES - @fetch_failed[f]
@fetch_tries ||= Hash.new { |h, k| h[k] = 1 }
if args.retry? && (@fetch_tries[f] < FETCH_MAX_TRIES)
wait = 2 ** @fetch_tries[f]
remaining = FETCH_MAX_TRIES - @fetch_tries[f]
what = "try".pluralize(remaining)
ohai "Retrying download in #{wait}s... (#{remaining} #{what} left)"
sleep wait
f.clear_cache
@fetch_failed[f] += 1
@fetch_tries[f] += 1
true
else
Homebrew.failed = true