Skip to content

Commit 6a2f3b0

Browse files
committed
Make sleep time and retries configurable in GlotpressDownloader
1 parent bfbea85 commit 6a2f3b0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ class GlotpressDownloader
77
AUTO_RETRY_SLEEP_TIME = 20
88
MAX_AUTO_RETRY_ATTEMPTS = 30
99

10-
def initialize(auto_retry: true)
10+
def initialize(
11+
auto_retry: true,
12+
auto_retry_sleep_time: 20,
13+
auto_retry_max_attempts: 30
14+
)
1115
@auto_retry = auto_retry
16+
@auto_retry_sleep_time = auto_retry_sleep_time
17+
@auto_retry_max_attempts = auto_retry_max_attempts
1218
@auto_retry_attempt_counter = 0
1319
end
1420

@@ -24,8 +30,8 @@ def download(glotpress_url)
2430
download(response.header['location'])
2531
when '429' # We got rate-limited, auto_retry or offer to try again with a prompt
2632
if @auto_retry && @auto_retry_attempt_counter <= MAX_AUTO_RETRY_ATTEMPTS
27-
UI.message("Received 429 for `#{response.uri}`. Auto retrying in #{AUTO_RETRY_SLEEP_TIME} seconds...")
28-
sleep(AUTO_RETRY_SLEEP_TIME)
33+
UI.message("Received 429 for `#{response.uri}`. Auto retrying in #{@auto_retry_sleep_time} seconds...")
34+
sleep(@auto_retry_sleep_time)
2935
@auto_retry_attempt_counter += 1
3036
download(response.uri)
3137
elsif UI.confirm("Retry downloading `#{response.uri}` after receiving 429 from the API?")

0 commit comments

Comments
 (0)