speed-up replicateZip - reduce CPU utilization and fix ZIP format errors#506
Open
jpstotz wants to merge 1 commit into
Open
speed-up replicateZip - reduce CPU utilization and fix ZIP format errors#506jpstotz wants to merge 1 commit into
jpstotz wants to merge 1 commit into
Conversation
…ressing and then compressing every entry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the step
ReplicateSinfipatool creates a new temporary file for adding the sinf data.To do so it reads and decompresses every entry of the downloaded ipa file and then recompresses and writes it to the newly created temp zip file.
This has two disadvantages:
only DEFLATED entries can have EXT descriptor. Just copying the ZIP header and data from the original data Apple provides does not have this problem.The small path for
replicateZipI propose in this PR fixes both problems:Using
OpenRaw()andCreateRaw()instead ofOpen()andCreateHeader()keeps the existing compressed entry bytes intact and avoids decompressing/recompressing during the SINF rewrite, while still preserving the original file header metadata carried byFileHeader.I tested the patched version with several apps. The downloaded ipa file is slightly smaller that the one created with ipatool before the patch. I tested the downloaded IPA files with several ZIP tools (7-zip, winrar, unzip, ..) and they all say "no errors detected" when testing the IPA files downloaded by the modified ipatool version.
In addition the downloaded ipa files could successfully be installed on a non-jailbroken iPhone running iOS 18.
Summary by cubic
Speeds up SINF replication by streaming raw compressed ZIP entries via OpenRaw/CreateRaw instead of decompressing/recompressing. This cuts CPU usage for large IPAs.
Written for commit 4a53e91. Summary will update on new commits.