[PR #1077] Remove ExtractAllEntries restriction for non-SOLID archives #1501

Closed
opened 2026-01-29 22:20:52 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1077

State: closed
Merged: Yes


Plan: Provide Single Interface for Entries (SOLID and non-SOLID)

  • Understand the problem and existing code
  • Remove the restriction in ExtractAllEntries() that prevents it from being called on non-SOLID archives
  • Ensure all archive types properly implement CreateReaderForSolidExtraction()
  • Add/update tests to verify ExtractAllEntries() works for all archive types
  • Run existing tests to ensure no regressions
  • Format code with CSharpier
  • Run code review
  • Run security scan
  • Update documentation
  • Rebase on latest master branch

Summary

Successfully rebased the PR on the latest master branch (commit eae25aff). All changes are preserved:

Changes Made:

  1. Removed restriction in AbstractArchive.cs: Deleted the check that threw an exception for non-SOLID archives in ExtractAllEntries()
  2. Added comprehensive tests: Created ExtractAllEntriesTests.cs with 12 tests covering all archive types and user scenarios
  3. Updated documentation: Enhanced USAGE.md with new example showing progress reporting pattern

Testing Results:

  • All 12 new ExtractAllEntriesTests pass ✓
  • All 221 existing ArchiveTests pass ✓
  • No regressions introduced

The branch is now up-to-date with master and ready for merge.

Original prompt

This section details on the original issue you should resolve

<issue_title>Provide single interface for dealing with Entries that are SOLID and not.</issue_title>
<issue_description>Issue: https://github.com/adamhathcock/sharpcompress/issues/960#issuecomment-3616319717

Sometimes you don't know if the file is a RAR or 7Zip that may have SOLID entries. The current interface requires you to know in advance about SOLID or not.

Provide an interface that doesn't require to know in advance.

ExtractAllEntries doesn't feel right to be used alongside Entry enumeration.

This is what used to work:

      public void ExtractToDirectory( string archivePath, string extractPath )
      {
          // Lock for Extraction Progress because of Singleton
          lock( extractToDictionarySyncObject )
          {
              var options = new ExtractionOptions() {
                  ExtractFullPath = true,
                  Overwrite = true
              };

              Directory.CreateDirectory( extractPath );

              using IArchive archive = ArchiveFactory.Open( archivePath );
              double totalSize = archive.Entries.Where( e => !e.IsDirectory ).Sum( e => e.Size );
              long completed = 0;

              IReader reader = archive.ExtractAllEntries();
              while( reader.MoveToNextEntry() )
              {
                  if( !reader.Entry.IsDirectory )
                  {
                      reader.WriteEntryToDirectory( extractPath, options );

                      completed += reader.Entry.Size;
                      ExtractionProgress?.Invoke( this, new ExtractionProgressEventArgs( completed / totalSize ) );
                  }
              }
          }
      }
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@adamhathcock</author><body>
This is the PR to revert probably https://github.com/adamhathcock/sharpcompress/pull/964</body></comment_new>
<comment_new><author>@adamhathcock</author><body>
Why is https://github.com/adamhathcock/sharpcompress/pull/1076 bad?

Maybe I should just allow it and https://github.com/adamhathcock/sharpcompress/issues/960 a different way</body></comment_new>
<comment_new><author>@adamhathcock</author><body>
@copilot see if there are any alternatives to the suggestions here</body></comment_new>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/1077 **State:** closed **Merged:** Yes --- ## Plan: Provide Single Interface for Entries (SOLID and non-SOLID) - [x] Understand the problem and existing code - [x] Remove the restriction in `ExtractAllEntries()` that prevents it from being called on non-SOLID archives - [x] Ensure all archive types properly implement `CreateReaderForSolidExtraction()` - [x] Add/update tests to verify `ExtractAllEntries()` works for all archive types - [x] Run existing tests to ensure no regressions - [x] Format code with CSharpier - [x] Run code review - [x] Run security scan - [x] Update documentation - [x] Rebase on latest master branch ## Summary Successfully rebased the PR on the latest master branch (commit eae25aff). All changes are preserved: ### Changes Made: 1. **Removed restriction in AbstractArchive.cs**: Deleted the check that threw an exception for non-SOLID archives in `ExtractAllEntries()` 2. **Added comprehensive tests**: Created `ExtractAllEntriesTests.cs` with 12 tests covering all archive types and user scenarios 3. **Updated documentation**: Enhanced USAGE.md with new example showing progress reporting pattern ### Testing Results: - All 12 new ExtractAllEntriesTests pass ✓ - All 221 existing ArchiveTests pass ✓ - No regressions introduced The branch is now up-to-date with master and ready for merge. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Provide single interface for dealing with Entries that are SOLID and not.</issue_title> > <issue_description>Issue: https://github.com/adamhathcock/sharpcompress/issues/960#issuecomment-3616319717 > > Sometimes you don't know if the file is a RAR or 7Zip that may have SOLID entries. The current interface requires you to know in advance about SOLID or not. > > Provide an interface that doesn't require to know in advance. > > `ExtractAllEntries` doesn't feel right to be used alongside Entry enumeration. > > This is what used to work: > ``` > public void ExtractToDirectory( string archivePath, string extractPath ) > { > // Lock for Extraction Progress because of Singleton > lock( extractToDictionarySyncObject ) > { > var options = new ExtractionOptions() { > ExtractFullPath = true, > Overwrite = true > }; > > Directory.CreateDirectory( extractPath ); > > using IArchive archive = ArchiveFactory.Open( archivePath ); > double totalSize = archive.Entries.Where( e => !e.IsDirectory ).Sum( e => e.Size ); > long completed = 0; > > IReader reader = archive.ExtractAllEntries(); > while( reader.MoveToNextEntry() ) > { > if( !reader.Entry.IsDirectory ) > { > reader.WriteEntryToDirectory( extractPath, options ); > > completed += reader.Entry.Size; > ExtractionProgress?.Invoke( this, new ExtractionProgressEventArgs( completed / totalSize ) ); > } > } > } > } > ```</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@adamhathcock</author><body> > This is the PR to revert probably https://github.com/adamhathcock/sharpcompress/pull/964</body></comment_new> > <comment_new><author>@adamhathcock</author><body> > Why is https://github.com/adamhathcock/sharpcompress/pull/1076 bad? > > Maybe I should just allow it and https://github.com/adamhathcock/sharpcompress/issues/960 a different way</body></comment_new> > <comment_new><author>@adamhathcock</author><body> > @copilot see if there are any alternatives to the suggestions here</body></comment_new> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes adamhathcock/sharpcompress#1070 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
claunia added the pull-request label 2026-01-29 22:20:52 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1501