@@ -29,11 +29,15 @@ def download(glotpress_url)
29
29
UI . message ( "Received 301 for `#{ response . uri } `. Following redirect..." )
30
30
download ( response . header [ 'location' ] )
31
31
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
37
41
elsif UI . confirm ( "Retry downloading `#{ response . uri } ` after receiving 429 from the API?" )
38
42
download ( response . uri )
39
43
else
@@ -51,9 +55,6 @@ def download(glotpress_url)
51
55
module Fastlane
52
56
module Helper
53
57
class MetadataDownloader
54
- AUTO_RETRY_SLEEP_TIME = 20
55
- MAX_AUTO_RETRY_ATTEMPTS = 30
56
-
57
58
attr_reader :target_folder , :target_files
58
59
59
60
def initialize ( target_folder , target_files , auto_retry )
@@ -159,22 +160,6 @@ def handle_glotpress_download(response:, locale:, is_source:)
159
160
loc_data = JSON . parse ( response . body ) rescue loc_data = nil
160
161
parse_data ( locale , loc_data , is_source )
161
162
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
178
163
else
179
164
message = "Received unexpected #{ response . code } from request to URI #{ response . uri } ."
180
165
UI . abort_with_message! ( message ) unless UI . confirm ( "#{ message } Continue anyway?" )
0 commit comments