[PR #1450] [MERGED] Client zip.rs reads archives with the zip crate it already links #3532

Closed
opened 2026-11-03 04:10:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1450
Author: @ludovic111
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @ludovic111

Base: main ← Head: chore/client-zip-crate


📝 Commits (1)

  • 60bad91 Client zip.rs reads archives with the zip crate it already links

📊 Changes

1 file changed (+122 additions, -84 deletions)

View changed files

📝 crates/horizon-client/src/zip.rs (+122 -84)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

Workstream 7 (review-plan.md §1 Duplication): the client's own ZIP reader (src/zip.rs: end-of-central-directory search, central directory and local header parsing by hand) is replaced by the zip crate the client already links (world backups) and that horizon-mods and horizon-shaderpack use.

  • Zip keeps its API (open, from_bytes, names, contains, read), so packs.rs, datapack.rs and font.rs are untouched.
  • The crate indexes the archive (zip64, prefixed archives and odd offsets included); names are still read with \ as / and folder entries left out.
  • Entries are read raw and inflated as before, without a CRC check: Java's ZipFile, which vanilla's FilePackResources reads packs with, doesn't check CRCs either (the crate's normal reader would refuse such entries). Same inflate size limit as before.
  • The reader code goes from ~110 lines to ~55; three tests are added for the odd zips the brief asked for, so the file is +122 / −84.

Proof

  • Old vs new reader on real archives, every entry's bytes compared (a throwaway tool with both versions side by side): the 26.3 client.jar (32,878 entries, 86 MB), server.jar, server-game.jar, the 1.13.2 and 1.20.6 server jars and vineflower: identical names and bytes for all 72,886 entries.
  • New unit tests: stored + deflated entries with zero CRCs (the existing hand-built archive), a zip-tool archive with folder entries, a nested Pack-main/ root, a deflated file and a Windows \ name; one broken deflate stream among good entries (only that read fails); not-a-zip, empty and truncated input refused.
  • Harnesses: parity.py resource_pack pack_selection pack_screen (a folder pack and a zip pack, selection, the packs screen): 3 passed (10.2 min). Shader packs read zips in horizon-shaderpack (its own zip crate code), unchanged.
  • Speed, client.jar, 3 rounds on a busy machine: open 10–59 ms (was 10–16 ms), reading all 32,878 entries 0.72–0.89 s (was 0.68–0.80 s): load-time only, nothing per frame.

Self-check

  • cargo fmt --all -- --check: OK
  • cargo clippy -p horizon-client --all-targets -- -D warnings: OK
  • cargo test -p horizon-client --lib: 1050 passed, 26 ignored
  • tools/parity.py --changed origin/main --list: 103 harnesses (the client crate); the 3 above run locally, the rest by CI.

Needs Ludovic

Nothing.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1450 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `chore/client-zip-crate` --- ### 📝 Commits (1) - [`60bad91`](https://github.com/horizon-rust/horizon/commit/60bad91a5004891ca5b746639a84c3a8b6538fdd) Client zip.rs reads archives with the zip crate it already links ### 📊 Changes **1 file changed** (+122 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/zip.rs` (+122 -84) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What Workstream 7 (review-plan.md §1 Duplication): the client's own ZIP reader (`src/zip.rs`: end-of-central-directory search, central directory and local header parsing by hand) is replaced by the `zip` crate the client already links (world backups) and that horizon-mods and horizon-shaderpack use. - `Zip` keeps its API (`open`, `from_bytes`, `names`, `contains`, `read`), so packs.rs, datapack.rs and font.rs are untouched. - The crate indexes the archive (zip64, prefixed archives and odd offsets included); names are still read with `\` as `/` and folder entries left out. - Entries are read raw and inflated as before, **without a CRC check**: Java's `ZipFile`, which vanilla's `FilePackResources` reads packs with, doesn't check CRCs either (the crate's normal reader would refuse such entries). Same inflate size limit as before. - The reader code goes from ~110 lines to ~55; three tests are added for the odd zips the brief asked for, so the file is +122 / −84. ## Proof - **Old vs new reader on real archives**, every entry's bytes compared (a throwaway tool with both versions side by side): the 26.3 client.jar (32,878 entries, 86 MB), server.jar, server-game.jar, the 1.13.2 and 1.20.6 server jars and vineflower: **identical names and bytes for all 72,886 entries**. - New unit tests: stored + deflated entries with zero CRCs (the existing hand-built archive), a zip-tool archive with folder entries, a nested `Pack-main/` root, a deflated file and a Windows `\` name; one broken deflate stream among good entries (only that read fails); not-a-zip, empty and truncated input refused. - Harnesses: `parity.py resource_pack pack_selection pack_screen` (a folder pack and a zip pack, selection, the packs screen): **3 passed** (10.2 min). Shader packs read zips in horizon-shaderpack (its own zip crate code), unchanged. - Speed, client.jar, 3 rounds on a busy machine: open 10–59 ms (was 10–16 ms), reading all 32,878 entries 0.72–0.89 s (was 0.68–0.80 s): load-time only, nothing per frame. ## Self-check - `cargo fmt --all -- --check`: OK - `cargo clippy -p horizon-client --all-targets -- -D warnings`: OK - `cargo test -p horizon-client --lib`: 1050 passed, 26 ignored - `tools/parity.py --changed origin/main --list`: 103 harnesses (the client crate); the 3 above run locally, the rest by CI. ## Needs Ludovic Nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:10:13 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3532
No description provided.