fix(updater): stop re-downloading special-char mods#51
Merged
Conversation
Mods whose canonical filename contained characters stripped by SanitizeFilename (spaces, brackets, apostrophes) were written to disk under a sanitized name, but the scan index, persisted state, and stale-jar matcher all keyed on the raw name. The on-disk file never matched, so every run re-downloaded the mod and left the old jar orphaned. Record both names per mod (RawFilename = canonical, Filename = on-disk) and key the filename index on every variant (raw, current sanitized, legacy sanitized) so a jar written by any past rule still resolves. reconcileSanitizedFilenames renames a drifted jar in place on a real run, never under --dry-run. With the map in place, loosen SanitizeFilename to the actually-valid cross-OS set: keep [] () ' spaces + - . _, decode %XX, replace only < > : " / \ | ? * and control chars, strip trailing dots/spaces, and guard Windows reserved device names. Closes #49 Refs #43
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.
Problem
Mods whose canonical filename contains characters stripped by
SanitizeFilename(spaces,[],(),') were written to disk under a sanitized name, but the scan filename index, persistedstate.Mods[].Filename, and stale-jar matcher all keyed on the raw name. The on-disk file never matched, so every run re-downloaded the mod and orphaned the old jar.Confirmed on a real instance:
BiblioCraft[v1.11.7][MC1.7.10].jar->BiblioCraftv1.11.7MC1.7.10.jar. 5 mods re-downloaded every run before the fix, 0 after.Fix
InstalledMod.RawFilename(canonical) andFilename(actual on-disk).fileutil.FilenameVariants(raw, current sanitized, legacy sanitized) so a jar written by any past rule still resolves.reconcileSanitizedFilenamesrenames a drifted jar in place on a real run; skipped under--dry-run(no filesystem side effects).Loosen sanitization
With the map bridging old/new names,
SanitizeFilenamenow allows the actually-valid cross-OS set:[] () ', spaces,+ - . _%XX(e.g.%2B->+)< > : " / \ | ? *and control chars with_Tests
fileutil/sanitize_test.go— full rule table +FilenameVariantsTestRun_SanitizedFilenameNotRedownloaded— legacy-named jar recognized as unchangedTestRun_LegacyNamedJarMigratedNoDuplicate— real update migrates in place, exactly one jar leftTestReconcileSanitizedFilenames(+ skip stale/clean), updated assets/maven testsgo build,go vet,go test ./...all passCloses #49
Refs #43