deliver/lib/deliver/upload_screenshots.rb in fastlane-2.150.0.rc1 vs deliver/lib/deliver/upload_screenshots.rb in fastlane-2.150.0.rc2

- old
+ new

@@ -32,15 +32,41 @@ # Only delete screenshots if trying to upload next unless screenshots_per_language.keys.include?(localization.locale) # Iterate over all screenshots for each set and delete screenshot_sets = localization.get_app_screenshot_sets + + # Multi threading delete on single localization + threads = [] + errors = [] + screenshot_sets.each do |screenshot_set| UI.message("Removing all previously uploaded screenshots for '#{localization.locale}' '#{screenshot_set.screenshot_display_type}'...") screenshot_set.app_screenshots.each do |screenshot| UI.verbose("Deleting screenshot - #{localization.locale} #{screenshot_set.screenshot_display_type} #{screenshot.id}") - screenshot.delete! + threads << Thread.new do + begin + screenshot.delete! + UI.verbose("Deleted screenshot - #{localization.locale} #{screenshot_set.screenshot_display_type} #{screenshot.id}") + rescue => error + UI.verbose("Failed to delete screenshot - #{localization.locale} #{screenshot_set.screenshot_display_type} #{screenshot.id}") + errors << error + end + end end + end + + sleep(1) # Feels bad but sleeping a bit to let the threads catchup + + unless threads.empty? + Helper.show_loading_indicator("Waiting for screenshots to be deleted for '#{localization.locale}'... (might be slow)") unless FastlaneCore::Globals.verbose? + threads.each(&:join) + Helper.hide_loading_indicator unless FastlaneCore::Globals.verbose? + end + + # Crash if any errors happen while deleting + unless errors.empty? + UI.crash!(errors.map(&:message).join("\n")) end end end # Finding languages to enable