@@ -29,11 +29,15 @@ def download(glotpress_url)
2929 UI . message ( "Received 301 for `#{ response . uri } `. Following redirect..." )
3030 download ( response . header [ 'location' ] )
3131 when '429' # We got rate-limited, auto_retry or offer to try again with a prompt
32- if @auto_retry && @auto_retry_attempt_counter <= MAX_AUTO_RETRY_ATTEMPTS
33- UI . message ( "Received 429 for `#{ response . uri } `. Auto retrying in #{ @auto_retry_sleep_time } seconds..." )
34- sleep ( @auto_retry_sleep_time )
35- @auto_retry_attempt_counter += 1
36- download ( response . uri )
32+ if @auto_retry
33+ if @auto_retry_attempt_counter < @auto_retry_max_attempts
34+ UI . message ( "Received 429 for `#{ response . uri } `. Auto retrying in #{ @auto_retry_sleep_time } seconds..." )
35+ sleep ( @auto_retry_sleep_time )
36+ @auto_retry_attempt_counter += 1
37+ download ( response . uri )
38+ else
39+ UI . error ( "Abandoning `#{ response . uri } ` download after #{ @auto_retry_attempt_counter } retries." )
40+ end
3741 elsif UI . confirm ( "Retry downloading `#{ response . uri } ` after receiving 429 from the API?" )
3842 download ( response . uri )
3943 else
@@ -51,9 +55,6 @@ def download(glotpress_url)
5155module Fastlane
5256 module Helper
5357 class MetadataDownloader
54- AUTO_RETRY_SLEEP_TIME = 20
55- MAX_AUTO_RETRY_ATTEMPTS = 30
56-
5758 attr_reader :target_folder , :target_files
5859
5960 def initialize ( target_folder , target_files , auto_retry )
@@ -159,22 +160,6 @@ def handle_glotpress_download(response:, locale:, is_source:)
159160 loc_data = JSON . parse ( response . body ) rescue loc_data = nil
160161 parse_data ( locale , loc_data , is_source )
161162 reparse_alternates ( target_locale , loc_data , is_source ) unless @alternates . empty?
162- when '301'
163- # Follow the redirect
164- UI . message ( "Received 301 for `#{ locale } `. Following redirect..." )
165- download ( locale , response . header [ 'location' ] , is_source )
166- when '429'
167- # We got rate-limited, auto_retry or offer to try again with a prompt
168- if @auto_retry && @auto_retry_attempt_counter <= MAX_AUTO_RETRY_ATTEMPTS
169- UI . message ( "Received 429 for `#{ locale } `. Auto retrying in #{ AUTO_RETRY_SLEEP_TIME } seconds..." )
170- sleep ( AUTO_RETRY_SLEEP_TIME )
171- @auto_retry_attempt_counter += 1
172- download ( locale , response . uri , is_source )
173- elsif UI . confirm ( "Retry downloading `#{ locale } ` after receiving 429 from the API?" )
174- download ( locale , response . uri , is_source )
175- else
176- UI . error ( "Abandoning `#{ locale } ` download as requested." )
177- end
178163 else
179164 message = "Received unexpected #{ response . code } from request to URI #{ response . uri } ."
180165 UI . abort_with_message! ( message ) unless UI . confirm ( "#{ message } Continue anyway?" )
0 commit comments