@@ -12,27 +12,24 @@ def initialize(auto_retry)
12
12
@auto_retry_attempt_counter = 0
13
13
end
14
14
15
- def download ( target_locale , glotpress_url , is_source )
15
+ def download ( glotpress_url )
16
16
uri = URI ( glotpress_url )
17
17
response = Net ::HTTP . get_response ( uri )
18
18
19
19
case response . code
20
- when '200'
21
- # All good pass the result along
20
+ when '200' # All good pass the result along
22
21
response
23
- when '301'
24
- # Follow the redirect
25
- UI . message ( "Received 301 for `#{ locale } `. Following redirect..." )
26
- download ( locale , response . header [ 'location' ] , is_source )
27
- when '429'
28
- # We got rate-limited, auto_retry or offer to try again with a prompt
22
+ when '301' # Follow the redirect
23
+ UI . message ( "Received 301 for `#{ response . uri } `. Following redirect..." )
24
+ download ( response . header [ 'location' ] )
25
+ when '429' # We got rate-limited, auto_retry or offer to try again with a prompt
29
26
if @auto_retry && @auto_retry_attempt_counter <= MAX_AUTO_RETRY_ATTEMPTS
30
27
UI . message ( "Received 429 for `#{ response . uri } `. Auto retrying in #{ AUTO_RETRY_SLEEP_TIME } seconds..." )
31
28
sleep ( AUTO_RETRY_SLEEP_TIME )
32
29
@auto_retry_attempt_counter += 1
33
- download ( target_locale , response . uri , is_source )
30
+ download ( response . uri )
34
31
elsif UI . confirm ( "Retry downloading `#{ response . uri } ` after receiving 429 from the API?" )
35
- download ( target_locale , response . uri , is_source )
32
+ download ( response . uri )
36
33
else
37
34
UI . error ( "Abandoning `#{ response . uri } ` download as requested." )
38
35
end
@@ -64,7 +61,7 @@ def initialize(target_folder, target_files, auto_retry)
64
61
# Downloads data from GlotPress, in JSON format
65
62
def download ( target_locale , glotpress_url , is_source )
66
63
downloader = GlotPressDownloader . new ( @auto_retry )
67
- response = downloader . download ( target_locale , glotpress_url , is_source )
64
+ response = downloader . download ( glotpress_url )
68
65
handle_glotpress_download ( response : response , locale : target_locale , is_source : is_source )
69
66
end
70
67
0 commit comments