deliver/lib/deliver/upload_screenshots.rb in fastlane-2.219.0 vs deliver/lib/deliver/upload_screenshots.rb in fastlane-2.220.0
- old
+ new
@@ -53,11 +53,11 @@
# Refresh version localizations
localizations = version.get_app_store_version_localizations
end
- upload_screenshots(localizations, screenshots_per_language)
+ upload_screenshots(localizations, screenshots_per_language, options[:screenshot_processing_timeout])
Helper.show_loading_indicator("Sorting screenshots uploaded...")
sort_screenshots(localizations)
Helper.hide_loading_indicator
@@ -107,11 +107,11 @@
else
UI.message("Successfully deleted all screenshots")
end
end
- def upload_screenshots(localizations, screenshots_per_language, tries: 5)
+ def upload_screenshots(localizations, screenshots_per_language, timeout_seconds, tries: 5)
tries -= 1
# Upload screenshots
worker = FastlaneCore::QueueWorker.new do |job|
begin
@@ -156,39 +156,46 @@
worker.start
UI.verbose('Uploading jobs are completed')
Helper.show_loading_indicator("Waiting for all the screenshots to finish being processed...")
- states = wait_for_complete(iterator)
+ states = wait_for_complete(iterator, timeout_seconds)
Helper.hide_loading_indicator
- retry_upload_screenshots_if_needed(iterator, states, total_number_of_screenshots, tries, localizations, screenshots_per_language)
+ retry_upload_screenshots_if_needed(iterator, states, total_number_of_screenshots, tries, timeout_seconds, localizations, screenshots_per_language)
UI.message("Successfully uploaded all screenshots")
end
# Verify all screenshots have been processed
- def wait_for_complete(iterator)
+ def wait_for_complete(iterator, timeout_seconds)
+ start_time = Time.now
loop do
states = iterator.each_app_screenshot.map { |_, _, app_screenshot| app_screenshot }.each_with_object({}) do |app_screenshot, hash|
state = app_screenshot.asset_delivery_state['state']
hash[state] ||= 0
hash[state] += 1
end
is_processing = states.fetch('UPLOAD_COMPLETE', 0) > 0
return states unless is_processing
+ if Time.now - start_time > timeout_seconds
+ UI.important("Screenshot upload reached the timeout limit of #{timeout_seconds} seconds. We'll now retry uploading the screenshots that couldn't be uploaded in time.")
+ return states
+ end
+
UI.verbose("There are still incomplete screenshots - #{states}")
sleep(5)
end
end
# Verify all screenshots states on App Store Connect are okay
- def retry_upload_screenshots_if_needed(iterator, states, number_of_screenshots, tries, localizations, screenshots_per_language)
+ def retry_upload_screenshots_if_needed(iterator, states, number_of_screenshots, tries, timeout_seconds, localizations, screenshots_per_language)
is_failure = states.fetch("FAILED", 0) > 0
+ is_processing = states.fetch('UPLOAD_COMPLETE', 0) > 0
is_missing_screenshot = !screenshots_per_language.empty? && !verify_local_screenshots_are_uploaded(iterator, screenshots_per_language)
- return unless is_failure || is_missing_screenshot
+ return unless is_failure || is_missing_screenshot || is_processing
if tries.zero?
iterator.each_app_screenshot.select { |_, _, app_screenshot| app_screenshot.error? }.each do |localization, _, app_screenshot|
UI.error("#{app_screenshot.file_name} for #{localization.locale} has error(s) - #{app_screenshot.error_messages.join(', ')}")
end
@@ -198,10 +205,10 @@
UI.error("Failed to upload all screenshots... Tries remaining: #{tries}")
# Delete bad entries before retry
iterator.each_app_screenshot do |_, _, app_screenshot|
app_screenshot.delete! unless app_screenshot.complete?
end
- upload_screenshots(localizations, screenshots_per_language, tries: tries)
+ upload_screenshots(localizations, screenshots_per_language, timeout_seconds, tries: tries)
end
end
# Return `true` if all the local screenshots are uploaded to App Store Connect
def verify_local_screenshots_are_uploaded(iterator, screenshots_per_language)