Skip to content

A first RAR volume isn't reopened to see whether the run restarts - #319

Open
xbmc4lyfe wants to merge 2 commits into
mainfrom
rar-policy-route-head-once
Open

xbmc4lyfe wants to merge 2 commits into
mainfrom
rar-policy-route-head-once

Conversation

@xbmc4lyfe

@xbmc4lyfe xbmc4lyfe commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Why

After #313, Prybar's pry extract of a 500 MB, 10-volume stored RAR5 set still read 1,048,590 bytes of part01 twice. pry extract and pry test set Options::restart_from_first_volume. With it, rar_run_shared_open opened the volume it was given, then called restart_volume. That ran starts_with_continuation, which opened the same volume again through Volume::open_with_password and read its whole MAX_SFX + 8 signature window a second time, just to see whether its first member continues from an earlier volume. The other 6 bytes are the ISO 9660 sniff at 32 KiB.

What

restart_volume looks at the name first. A volume with no earlier volume by name (part1, or the .rar of an old-style set) can never restart, so it is not reopened. Before, that case also returned None, but only after the probe, so the result is the same. A run given a later volume still probes it and restarts as before.

All the dispatchers go through rar_run_shared_open, so this one change covers run_with_zip_policy / run_with_policy / run_with_context, run / run_with_password, and run_rar_with_outcomes. list_detailed_with_options never restarts. It already reads each header once and is now covered by a test. RarSession's own restart probe (Catalogue::restart_volume, budgeted and only with follow_volumes) is unchanged.

Measured

These numbers come from strace -f -ff -y of a release build on rustyget-x86-d. The harness is an uncommitted example calling run_with_zip_policy with restart_from_first_volume and replace_placed_links, as pry extract does. The set is a 500 MB stored RAR5 set made by rar a -m0 -ma5 -v52428800b (part01–part10 at 50 MiB, plus a 1,858-byte part11). The output matches the input byte for byte in both runs.

part01 read / unique / dup set read / unique / dup
before (main 2d03962) 53,477,390 / 52,428,800 / 1,048,590 525,338,448 / 524,289,858 / 1,048,590
after (e50fd7d) 52,428,806 / 52,428,800 / 6 524,289,864 / 524,289,858 / 6

The "before" figure is exactly the 1,048,590 bytes Prybar saw. The 6 left on part01 are the ISO 9660 sniff at 32 KiB, as after #313. Every other volume is read once.

Tests

  • extract::read_once::every_dispatcher_reads_each_volume_once_when_it_may_restart runs run_with_zip_policy, run_with_password and run_rar_with_outcomes with restart_from_first_volume and replace_placed_links (as pry extract does), and lists with list_detailed_with_options. Each runs with and without a 100 KB SFX prefix, and every volume must be read once (VOLUME_READS). On main it fails with set.part1.rar: read (0, 1048584) with 1024 read so far.
  • extract::read_once::a_run_from_a_later_volume_still_restarts checks that a run given part2 still extracts the whole set.

Local: the extract::read_once tests and cargo nextest over the RAR and volume tests (987) pass. fmt and clippy are clean.

Clean-room: no third-party code read or used.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj

With Options::restart_from_first_volume (what `pry extract` and `pry test`
pass), every RAR run opened the volume it was given a second time, reading
its 1 MiB signature window again, only to learn whether its first member
continues from an earlier volume. A volume with none before it by name
(part1, an old-style set's .rar) can never restart, so the name is checked
first and the volume isn't reopened. A run from a later volume restarts as
before.

Covers run_with_zip_policy / run_with_policy, run_with_password and
run_rar_with_outcomes, with and without a self-extractor prefix, and
list_detailed_with_options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T03:43:12.029461Z 8e5e4ea Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: e50fd7d2c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 8e5e4ea9b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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