-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
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.
2f7ce6d
to
4052535
Compare
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. |
There was a problem hiding this 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.
Oh, and on your second comment:
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellente. Thanks
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