Skip to content

Commit 17ca0b7

Browse files
committed
Limit number of auto_retry attempts in metadata_download_helper
1 parent 8fa9163 commit 17ca0b7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Fastlane
55
module Helper
66
class MetadataDownloader
77
AUTO_RETRY_SLEEP_TIME = 20
8+
MAX_AUTO_RETRY_ATTEMPTS = 30
89

910
attr_reader :target_folder, :target_files
1011

@@ -13,6 +14,7 @@ def initialize(target_folder, target_files, auto_retry)
1314
@target_files = target_files
1415
@auto_retry = auto_retry
1516
@alternates = {}
17+
@auto_retry_attempt_counter = 0
1618
end
1719

1820
# Downloads data from GlotPress, in JSON format
@@ -116,9 +118,10 @@ def handle_glotpress_download(response:, locale:, is_source:)
116118
download(locale, response.header['location'], is_source)
117119
when '429'
118120
# We got rate-limited, auto_retry or offer to try again with a prompt
119-
if @auto_retry
121+
if @auto_retry && @auto_retry_attempt_counter <= MAX_AUTO_RETRY_ATTEMPTS
120122
UI.message("Received 429 for `#{locale}`. Auto retrying in #{AUTO_RETRY_SLEEP_TIME} seconds...")
121123
sleep(AUTO_RETRY_SLEEP_TIME)
124+
@auto_retry_attempt_counter += 1
122125
download(locale, response.uri, is_source)
123126
elsif UI.confirm("Retry downloading `#{locale}` after receiving 429 from the API?")
124127
download(locale, response.uri, is_source)

0 commit comments

Comments
 (0)