Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pilot] Fix Large File Upload Issues in Mac pkg Deployment #21906

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 27 additions & 3 deletions fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
Expand Up @@ -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
}
Expand All @@ -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