Skip to content

Conversation

@adamhathcock
Copy link
Owner

Explicit exception for #960

@adamhathcock adamhathcock requested a review from Copilot October 21, 2025 12:54
Copy link
Contributor

Copilot AI left a 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 throw InvalidOperationException for non-solid, non-7Zip archives
  • Refactored test code to use ReaderFactory.Open() directly instead of ArchiveFactory.Open() followed by ExtractAllEntries()
  • Added convenience Open() methods to ReaderFactory and RarReader for 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>
@adamhathcock adamhathcock merged commit c061254 into master Oct 21, 2025
2 checks passed
@adamhathcock adamhathcock deleted the adam/extract-all-solid-only branch October 21, 2025 13:08
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