-
Notifications
You must be signed in to change notification settings - Fork 499
Only allow extract all on archives that are solid (some rars and 7zip only) #964
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
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.
Pull Request Overview
This PR restricts the use of ExtractAllEntries() to only solid archives (some RAR formats) and 7Zip archives, throwing an explicit exception for non-solid archives. This addresses issue #960 by preventing misuse of the API on archive types that don't require sequential extraction.
Key Changes:
- Added validation in
ExtractAllEntries()to throwInvalidOperationExceptionfor non-solid, non-7Zip archives - Refactored test code to use
ReaderFactory.Open()directly instead ofArchiveFactory.Open()followed byExtractAllEntries() - Added convenience
Open()methods toReaderFactoryandRarReaderfor file path inputs
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/SharpCompress/Archives/AbstractArchive.cs | Added validation check to prevent ExtractAllEntries() on non-solid, non-7Zip archives |
| src/SharpCompress/Archives/IArchiveExtensions.cs | Changed ExtractToDirectory() to iterate archive entries directly instead of using ExtractAllEntries() |
| src/SharpCompress/Readers/ReaderFactory.cs | Added Open() overloads accepting file paths and FileInfo objects |
| src/SharpCompress/Readers/Rar/RarReader.cs | Added Open() overloads for single and multiple file paths |
| tests/SharpCompress.Test/ArchiveTests.cs | Updated tests to use direct entry iteration and removed redundant method overload |
| tests/SharpCompress.Test/Zip/ZipArchiveTests.cs | Replaced ArchiveFactory.Open() + ExtractAllEntries() with ReaderFactory.Open() |
| tests/SharpCompress.Test/Zip/ZipReaderTests.cs | Updated test to use ReaderFactory.Open() directly and added clarifying comment |
| tests/SharpCompress.Test/Rar/RarReaderTests.cs | Changed to use RarReader.Open() with explicit file list instead of archive |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Explicit exception for #960