Skip to content

fix: harden restricted download continuation#61

Merged
mannie-exe merged 1 commit into
mainfrom
dev
Apr 12, 2026
Merged

fix: harden restricted download continuation#61
mannie-exe merged 1 commit into
mainfrom
dev

Conversation

@mannie-exe
Copy link
Copy Markdown
Contributor

@mannie-exe mannie-exe commented Apr 12, 2026

Summary

  • decode subprocess output with Windows codepage fallback so restricted filenames like §6No Enchant Glint 1.20.1.zip survive parsing and persistence
  • record a watched-file baseline for pending restricted builds and use it to distinguish new manual downloads from pre-existing recent zip noise
  • add regression coverage for DeceasedCraft-style filenames, baseline-aware matching, and interactive legacy pending recovery

Test plan

  • cargo test -q -p empack-lib --features test-utils --no-run
  • cargo test -q -p empack-lib --features test-utils process_output_decoder_prefers_utf8_when_valid -- --nocapture
  • cargo test -q -p empack-lib --features test-utils parse_export_restricted_output_preserves_deceasedcraft_section_sign_filename -- --nocapture
  • cargo test -q -p empack-lib --features test-utils import_matching_downloads_into_cache_ignores_preexisting_recent_zip_noise_when_baseline_exists -- --nocapture
  • cargo test -q -p empack-lib --features test-utils build_continue_detects_exact_deceasedcraft_section_sign_filename -- --nocapture
  • cargo test -q -p empack-lib --features test-utils interactive_wait_loop_captures_baseline_for_legacy_pending_before_polling -- --nocapture
  • cargo test -q -p empack-lib --features test-utils restricted_build -- --nocapture
  • cargo test -q -p empack-lib --features test-utils commands -- --nocapture
  • cargo test -q -p empack-tests --test build_continue -- --nocapture
  • cargo fmt --all
  • git diff --check

Notes

  • cargo check --target x86_64-pc-windows-msvc --tests could not run locally because that target is not installed in this environment.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 12, 2026

Codecov Report

❌ Patch coverage is 95.86645% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/empack-lib/src/empack/restricted_build.rs 82.63% 25 Missing ⚠️
crates/empack-lib/src/application/commands.rs 94.11% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 12, 2026

Greptile Summary

This PR addresses two distinct Windows-specific failure modes in the restricted build workflow: (1) subprocess output containing CP1252-encoded filenames (e.g. §6No Enchant Glint 1.20.1.zip) was corrupted by the existing from_utf8_lossy decoder, and (2) pre-existing recent zip files in the downloads directory caused the legacy fallback to be ambiguous and refuse to import the correct download. It resolves both by adding MultiByteToWideChar-based codepage decoding (Windows-only, UTF-8 preferred) and by recording a watched-file baseline before polling so only genuinely new files are treated as candidates.

Confidence Score: 5/5

Safe to merge — no correctness, data-integrity, or security issues found.

All changes are well-scoped fixes with comprehensive regression tests. The Windows codepage decoder correctly prefers UTF-8, the baseline logic cleanly supersedes the legacy timestamp fallback without breaking it for older pending state, and every new code path is covered by unit and integration tests. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
crates/empack-lib/src/application/session.rs Adds decode_process_output_chunk with platform-conditional logic: on Windows, prefers UTF-8 then falls back through console/ANSI/OEM codepages via MultiByteToWideChar; on non-Windows uses from_utf8_lossy. Implementation is correct and well-tested.
crates/empack-lib/src/empack/restricted_build.rs Adds PendingRestrictedCandidateSnapshot, candidate_baseline field (serde-defaulted for backward compat), capture_candidate_baseline, snapshot_changed, and find_new_or_changed_candidate; import logic correctly prefers baseline-aware over legacy timestamp fallback when a baseline exists.
crates/empack-lib/src/application/commands.rs Wires baseline capture after saving the pending build (two-step persist is intentional for crash-recovery); interactive wait loop captures baseline for legacy pending before polling — graceful degradation path is explicitly covered.
crates/empack-lib/src/empack/restricted_build.test.rs Good unit test coverage added: exact DeceasedCraft filename, baseline noise suppression, baseline ambiguity guard, modified-time fallback, and round-trip serialization of candidate_baseline.
crates/empack-lib/src/empack/packwiz.test.rs Adds test_restricted_destination_filename_preserves_section_sign and test_parse_export_restricted_output_preserves_deceasedcraft_section_sign_filename — correctly exercises the UTF-8 preservation path through the packwiz output parser.
crates/empack-lib/src/application/commands.test.rs Integration tests cover exact DeceasedCraft filename detection, baseline noise suppression on --continue, and the interactive wait-loop baseline capture for legacy pending builds including the threaded write-after-delay scenario.

Reviews (2): Last reviewed commit: "fix: harden restricted download continua..." | Re-trigger Greptile

@mannie-exe
Copy link
Copy Markdown
Contributor Author

@greptileai

@mannie-exe mannie-exe merged commit 745e5a8 into main Apr 12, 2026
9 of 13 checks passed
@mannie-exe mannie-exe deleted the dev branch April 12, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant