diff --git a/fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb b/fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb index c96b864ed2d..b208cdd3df4 100644 --- a/fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb +++ b/fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb @@ -22,7 +22,7 @@ def generate(app_id: nil, pkg_path: nil, package_path: nil, platform: "osx") apple_id: app_id, file_size: File.size(pkg_path), ipa_path: File.basename(pkg_path), # this is only the base name as the ipa is inside the package - md5: Digest::MD5.hexdigest(File.read(pkg_path)), + md5: calculate_md5(pkg_path), archive_type: 'product-archive', platform: platform } @@ -41,9 +41,33 @@ def generate(app_id: nil, pkg_path: nil, package_path: nil, platform: "osx") def copy_pkg(pkg_path) ipa_file_name = Digest::MD5.hexdigest(pkg_path) resulting_path = File.join(self.package_path, "#{ipa_file_name}.pkg") - FileUtils.cp(pkg_path, resulting_path) - resulting_path + begin + File.open(pkg_path, 'rb') do |src| + File.open(resulting_path, 'wb') do |dst| + while (buffer = src.read(1024 * 1024)) do + dst.write(buffer) + end + end + end + return resulting_path + rescue StandardError => e + UI.user_error!("Error copying file '#{pkg_path}' to '#{resulting_path}': #{e.message}") + end + end + + def calculate_md5(file_path) + begin + md5 = Digest::MD5.new + File.open(file_path, 'rb') do |file| + while (buffer = file.read(1024 * 1024)) do + md5.update(buffer) + end + end + return md5.hexdigest + rescue StandardError => e + UI.user_error!("Error reading file '#{file_path}': #{e.message}") + end end end end