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

Add support for large iOS application packages #342

Merged
merged 4 commits into from
Sep 4, 2023

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Sep 4, 2023

Creating Ipa instances from large archives (4+GB) results in the following exception:

Traceback (most recent call last):
  File "/Users/builder/.pyenv/versions/3.8.13/lib/python3.8/site-packages/codemagic/models/application_package/ipa.py", line 23, in _validate_package
    return bool(self.info_plist)
  File "/Users/builder/.pyenv/versions/3.8.13/lib/python3.8/site-packages/codemagic/models/application_package/ipa.py", line 83, in info_plist
    return self._get_info_plist()
  File "/Users/builder/.pyenv/versions/3.8.13/lib/python3.8/site-packages/codemagic/models/application_package/ipa.py", line 77, in _get_info_plist
    info_plist_contents = self._get_app_file_contents("Info.plist")
  File "/Users/builder/.pyenv/versions/3.8.13/lib/python3.8/site-packages/codemagic/models/application_package/ipa.py", line 57, in _get_app_file_contents
    return self._extract_file(filename_filter)
  File "/Users/builder/.pyenv/versions/3.8.13/lib/python3.8/site-packages/codemagic/models/application_package/ipa.py", line 35, in _extract_file
    with zf.open(found_file_name, "r") as fd:
  File "/Users/builder/.pyenv/versions/3.8.13/lib/python3.8/zipfile.py", line 1532, in open
    raise BadZipFile("Truncated file header")
zipfile.BadZipFile: Truncated file header

Similar error occurs when unzip is used:

$ unzip -p app.ipa Payload/Runner.app/Info.plist
warning [app.ipa]:  17179869184 extra bytes at beginning or within zipfile
  (attempting to process anyway)
file #1:  bad zipfile offset (lseek):  17362427904

This is because macOS creates corrupt zip archives when the file size exceeds 4GB (more information on the matter can be read from this SO answer: https://stackoverflow.com/a/59518097). 7-Zip is capable of handling such archives and this PR adds a fallback to use 7z in case zipfile.BadZipFile: Truncated file header error is encountered.

@priitlatt priitlatt added the bug Something isn't working label Sep 4, 2023
@priitlatt priitlatt marked this pull request as ready for review September 4, 2023 13:28
@priitlatt priitlatt merged commit 45dfff5 into master Sep 4, 2023
@priitlatt priitlatt deleted the bugfix/large-ipa-support branch September 4, 2023 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants