fix: don't include untouched files in build output#244
Open
bouclem wants to merge 1 commit into
Open
Conversation
Fixes MCPHackers#237. Two bugs caused unmodified files to leak into the build: TaskReobfuscate's extract filter looked up the obfuscated outer-class name in the deobfuscated-by-obf map, which always missed for inner classes. The hash lookup then returned null and forced extract=true, so unchanged inner classes were always reobfuscated and bundled. Resolve the deobfuscated name first, then strip the inner-class suffix for the hash key. TaskBuild packed every non-class file under bin/ into the build zip without consulting the recorded hashes. Now compares each asset against the original MD5 file and only includes new or modified ones, matching the behavior already used for classes.
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.
Fixes #237.
Two bugs were causing unmodified files to leak into build output (e.g. user reports
gui/items.png,terrain.png,ItemArmor$EnumArmorMaterial.class,TileEntityFurnace$1.classending up in the zip even though they weren't touched after the MD5 update).Bug 1 - Inner classes always extracted in
TaskReobfuscateThe
FileUtil.extractfilter stripped$...from the obfuscated entry name, then looked the result up inreversedNames(a map keyed by obfuscated outer-class names). Inner classes have entries likeItemArmor$EnumArmorMaterial, and stripping the inner suffix givesItemArmor- which isn't in the obfuscated map. The lookup returned null, the code fell back to using the obfuscated name as the deobf name, the hash lookup also missed, andextractwas forced to true unconditionally.Fix: resolve the deobfuscated name first (try the full entry name, then fall back to the outer class), then strip the inner-class suffix from that deobf name to build the hash key.
Bug 2 - Asset files never compared against MD5
TaskBuildwalked every non-class file underbin/and packed it into the build zip with no hash check, so any asset that was just a copy of the original (e.g. an unmodifiedterrain.pngleft over from the source layout) was always bundled.TaskUpdateMD5already records hashes for these files, the build step just wasn't reading them.Fix: in
TaskBuild, read the original MD5 file once and only include assets whose current hash differs from the recorded one (or that have no recorded hash, i.e. genuinely new files).Testing
gradlew buildpasses