Repository navigation
RAR5: plan and frame a dead volume from its siblings, exact or virtual (RustyGet) - #369
Merged
Merged
Conversation
Collaborator
Author
|
@codex review |
xbmc4lyfe
force-pushed
the
rar5-dead-volume-planner
branch
from
November 30, 2026 16:34
02a3246 to
2449e7e
Compare
…l (RustyGet) plan_dead_volumes places each dead volume of a stored RAR set: the member offset from the earlier parts, the template from the nearest agreeing middle siblings (same volume number width preferred, shifted across a width boundary, an identical intact sibling for damaged framing), the NZB and par2 length rules, and the last-volume rule. It stops at the first problem with a typed PlanStop and keeps the plans made before it. Each plan reports its mode (Exact or Virtual) and a typed reason. frame_dead_volume builds the frame: Exact through rebuild_volume_headers, or Virtual (main header without its locator, file header with the given CRC32 or none, end header only). It reads the frame back through the RAR 5.0 header reader with zeros for the part. Every refusal is typed. whole_file_crc32 combines part CRC32s for a dead last volume. Clean-room: from the prose spec, the RAR 5.0 format description and observed rar/UnRAR behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
… template's file (review) - The parts must add up to the member: when a readable volume closes it, or the sum passes it after a dead volume was planned, planning stops with MemberSizeMismatch and drops every earlier plan. - A dead last volume holds no more than a middle volume's part (LastTooLarge). - While the member is open, every readable volume after the first must be split-before. - The read-back requires the member's full name and unpacked size; a template with a redirection (symbolic or hard link) record is refused (TemplateFault::Redirection). - An exact frame that does not read back falls back to Virtual with ExactRefused(ReadBack). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
xbmc4lyfe
force-pushed
the
rar5-dead-volume-planner
branch
from
November 30, 2026 17:34
2449e7e to
c7d22e9
Compare
Collaborator
Author
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.
Implements the RustyGet request (b): placing a dead RAR 5.0 volume of a stored set, and framing it from a readable sibling. Clean-room: written from the prose behavioural spec, the RAR 5.0 format description and observed behaviour of rar/UnRAR output.
API (
zipfast::rar5, docs:docs/rar5-dead-volume.md)plan_dead_volumes(&[VolumeState], &MemberInfo, &PlanOptions) -> DeadVolumePlans { plans, stop: Option<PlanStop> }VolumeState::{Readable(ReadableVolume { version, len, part_start, part_len, split_before, split_after, framing_intact }), Dead(DeadVolume { nzb_size, exact_len, part_crc }), Unknown}MemberInfo { name, unpacked_size, headers_encrypted, encrypted, compressed, blake2sp },PlanOptions { prefer_exact }DeadVolumePlangives the dead index, template index (and its layout), member offset, part length, volume/head/tail lengths,width_shift,last/last_fit,mode: FrameMode::{Exact, Virtual}andreason: ModeReason::{PartCrcAndExactLength, VirtualRequested, NoPartCrc, NoExactLength, ExactRefused(ExactRefusal)}DeadVolumePlan::with_part_crc(crc)for a CRC learned laterframe_dead_volume(&DeadVolumePlan, &MemberInfo, &FrameInput { template_head, template_tail, earlier_parts_complete, borrowed_len }) -> Result<DeadVolumeFrame, FrameRefusal>rebuild_volume_headers(byte for byte as rar wrote it). If it is refused, does not match the plan, or does not read back, the frame falls back to Virtual and says why.VolumeMapBuilderwith zeros for the part, and checked as the spec's "what is verified" lists, plus the member's full name and unpacked size; a template with a redirection (symbolic or hard link) record is refusedwhole_file_crc32(&[(crc, len)]): part CRC32s combined in order, for a dead last volumeEvery refusal is typed:
PlanStop(Unusable(..),FirstNotReadable,NotReadable,NoTemplate { NoSibling | Disagree | FramingDamaged },MayBeLast,LastNeedsPar2Len,LastLenMismatch,LastTooLarge,NzbSizeMisfit,ExactLenMisfit,PastMemberEnd,MoreThanMember,MemberSizeMismatch(drops every earlier plan),Rar4LastVolume,MixedVersions,Inconsistent,EmptySet), plusFrameRefusal(UnsupportedVersion,TemplateChanged,Template(TemplateFault),LastVolumeIncomplete,LastVolumeNeedsCrc,BorrowedLengthDiffers,Overflow,ReadBack(..)).Review fixes (second commit)
MemberSizeMismatchand drops every earlier plan. Past anUnknownvolume, the sum cannot be checked.LastTooLarge).TemplateFault::Redirectionrefuses symbolic and hard link records.ExactRefused(ReadBack)).Tests (
tests/rar5_dead_volume.rs, 18 tests)whole_file_crc32, and Virtual. The par2 bare/framed/mismatch rules and NZB slack are checked.PlanStop,TemplateFaultand frame refusal is reached. The review's proof cases (sum mismatch, oversized last, missing split-before, other dir/size/links) are now tests of the fixed behaviour. Hostile input: 20k random extreme sets; bit flips at every byte of a real template plus every cut; junk heads; contradictory siblings.Related suites pass: rar5_volume_headers, rar5_volume_tail, uniform_volumes, last_volume_identity, rar4_volume_tail, container_rebuild*. fmt and both clippy runs pass.
Not done here: the spec's "streamable video or nested archive" check is RustyGet policy and stays with the caller (noted in the docs).
🤖 Generated with Claude Code
https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi