Skip to content

feat(rar): add support for multi-volume rar archives #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025

Conversation

darkliquid
Copy link
Contributor

The RAR archive format supports multi-volume archives. These are archives that are split across multiple files and extracting files from them requires reading through each of the 'volumes' until all the data is retrieved.

For streaming, this doesn't make sense (as you could just stream all the data in a single stream - no reason to split it) but for reading from disk, the way this is now handled is by setting an additional field on the Rar struct.

The Name field specifies the filename of the first volume in the multi-volume archive. This is important as this name is used to derive the names of subsequent volumes in the archive.

Additionally, you can also set an FS field on the Rar struct. If set, this forces the extractor to load volumes from the provided fs.FS rather than directly via OS.

Addresses #20

The RAR rchive format supports multi-volume archives. These are archives
that are split across multiple files and extracting files from them
requires reading through each of the 'volumes' until all the data is
retrieved.

For streaming, this doesn't make sense (as you could just stream all the
data in a single stream - no reason to split it) but for reading from
disk, the way this is now handled is by setting an additional field on
the Rar struct.

The Name field specifies the filename of the _first_ volume in the
multi-volume archive. This is important as this name is used to
derive the names of subsequent volumes in the archive.

Additionally, you can also set an FS field on the Rar struct. If set,
this forces the extractor to load volumes from the provided fs.FS rather
than directly via OS.
@darkliquid darkliquid force-pushed the feat/multi-volume-rar-support branch from 2f7ce6d to 4052535 Compare May 5, 2025 13:31
@darkliquid
Copy link
Contributor Author

While this PR makes it possible to handle multi-volume rar archives, I'm not sure whether there is an argument for making a whole new interface for this kind of thing, something like:

type MultiVolume interface {
    Volumes() []fs.File
}

and then building out all the supporting code for handling that.

But that would be a much bigger PR and probably worth considering a major version bump if the supporting code warranted existing API breakage.

Copy link
Owner

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This change actually looks pretty good, though it might change a little before 1.0. (which is fine)

Can we enhance the comments on Name and FS before we merge? We should make it clear that Name is associated with the FS field... and explain what those two fields do and how to use them.

@mholt
Copy link
Owner

mholt commented May 6, 2025

Oh, and on your second comment:

But that would be a much bigger PR and probably worth considering a major version bump if the supporting code warranted existing API breakage.

Yeah, let's maybe discuss that in the issue first, or a draft PR. (How many formats support multi-volume archives?)

@darkliquid
Copy link
Contributor Author

Yeah, let's maybe discuss that in the issue first, or a draft PR. (How many formats support multi-volume archives?)

I don't know many off the top of my head beyond 7zip, rar, cab and technically zip, though in my experience I've found support for multi-part zips patchy at best.

Copy link
Owner

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellente. Thanks

@mholt mholt merged commit d07f56a into mholt:main May 6, 2025
3 checks passed
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.

2 participants