Skip to content

Commit eab670b

Browse files
authored
Merge pull request #402 from wordpress-mobile/l10n/429-retry
Add an option to retry when GlotPress download fails on "429 Too Many Requests" errors
2 parents 57e7e31 + 840740b commit eab670b

File tree

5 files changed

+5
-1
lines changed

5 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _None_
1010

1111
### New Features
1212

13-
_None_
13+
- Propose to retry when the download of GlotPress translations failed for a locale (especially useful for occurrences of `429 - Too Many Requests` quota limits) [#402]
1414

1515
### Bug Fixes
1616

lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def self.download_glotpress_export_file(project_url:, locale:, filters:)
291291
uri.open(options) { |f| Nokogiri::XML(f.read.gsub("\t", ' '), nil, Encoding::UTF_8.to_s) }
292292
rescue StandardError => e
293293
UI.error "Error downloading #{locale} - #{e.message}"
294+
retry if e.is_a?(OpenURI::HTTPError) && UI.confirm("Retry downloading `#{locale}`?")
294295
return nil
295296
end
296297
end

lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def self.download_glotpress_export_file(project_url:, locale:, filters:, destina
152152
IO.copy_stream(uri.open(options), destination)
153153
rescue StandardError => e
154154
UI.error "Error downloading locale `#{locale}` — #{e.message} (#{uri})"
155+
retry if e.is_a?(OpenURI::HTTPError) && UI.confirm("Retry downloading `#{locale}`?")
155156
return nil
156157
end
157158
end

spec/ios_download_strings_files_from_glotpress_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_gp_download(filters:, tablename:, expected_gp_params:)
7070
stub = gp_stub(locale: 'unknown-locale', query: { 'filters[status]': 'current', format: 'strings' }).to_return(status: [404, 'Not Found'])
7171
error_messages = []
7272
allow(FastlaneCore::UI).to receive(:error) { |message| error_messages.append(message) }
73+
allow(FastlaneCore::UI).to receive(:confirm).and_return(false) # as we will be asked if we want to retry when getting a network error
7374

7475
# Act
7576
run_described_fastlane_action(

spec/ios_l10n_helper_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ def file_encoding(path)
260260
stub = stub_request(:get, "#{gp_fake_url}/invalid/default/export-translations/").with(query: { format: 'strings' }).to_return(status: [404, 'Not Found'])
261261
error_messages = []
262262
allow(FastlaneCore::UI).to receive(:error) { |message| error_messages.append(message) }
263+
allow(FastlaneCore::UI).to receive(:confirm).and_return(false) # as we will be asked if we want to retry when getting a network error
263264
dest = StringIO.new
264265
# Act
265266
described_class.download_glotpress_export_file(project_url: gp_fake_url, locale: 'invalid', filters: nil, destination: dest)

0 commit comments

Comments
 (0)