Solid Multipart RAR4.x archive - Fails but works with 2 comments. #328

Closed
opened 2026-01-29 22:10:12 +00:00 by claunia · 2 comments
Owner

Originally created by @Nanook on GitHub (Oct 10, 2018).

Solid Multipart RAR4.x archive fails to decompress due to 2 if statements intentionally throwing exceptions. When these 2 checks are commented out the archive extracts without issue.

I have tried various other approaches that all failed. Either complaining that it is solid and to use ExtractAllFiles(). When Trying ExtractAllFiles it complained that it was MultiVolume.

My successful test was using the following method.

 IArchive archive = ArchiveFactory.Open(@"PathAndFilename"); //handles multipart archives
 archive.WriteToDirectory(@"c:\test");

and commenting out the following code:

    public static class IArchiveEntryExtensions
    {
        public static void WriteTo(this IArchiveEntry archiveEntry, Stream streamToWriteTo)
        {
            //Nanook
            //if (archiveEntry.Archive.Type == ArchiveType.Rar && archiveEntry.Archive.IsSolid)
            //{
            //    throw new InvalidFormatException("Cannot use Archive random access on SOLID Rar files.");
            //}

and in RarArchiveEntry.cs

        public Stream OpenEntryStream()
        {
            //Nanook
            //if (archive.IsSolid)
            //{
            //    throw new InvalidOperationException("Use ExtractAllEntries to extract SOLID archives.");
            //}

I realise there's probably a legitimate reason for these checks. I just wanted to raise this for consideration.

Thanks for a great compression library.

Originally created by @Nanook on GitHub (Oct 10, 2018). Solid Multipart RAR4.x archive fails to decompress due to 2 if statements intentionally throwing exceptions. When these 2 checks are commented out the archive extracts without issue. I have tried various other approaches that all failed. Either complaining that it is solid and to use ExtractAllFiles(). When Trying ExtractAllFiles it complained that it was MultiVolume. My successful test was using the following method. ``` IArchive archive = ArchiveFactory.Open(@"PathAndFilename"); //handles multipart archives archive.WriteToDirectory(@"c:\test"); ``` and commenting out the following code: ``` public static class IArchiveEntryExtensions { public static void WriteTo(this IArchiveEntry archiveEntry, Stream streamToWriteTo) { //Nanook //if (archiveEntry.Archive.Type == ArchiveType.Rar && archiveEntry.Archive.IsSolid) //{ // throw new InvalidFormatException("Cannot use Archive random access on SOLID Rar files."); //} ``` and in RarArchiveEntry.cs ``` public Stream OpenEntryStream() { //Nanook //if (archive.IsSolid) //{ // throw new InvalidOperationException("Use ExtractAllEntries to extract SOLID archives."); //} ``` I realise there's probably a legitimate reason for these checks. I just wanted to raise this for consideration. Thanks for a great compression library.
claunia added the enhancementup for grabs labels 2026-01-29 22:10:12 +00:00
Author
Owner

@adamhathcock commented on GitHub (Nov 2, 2018):

I guess I didn't cover the scenario of multi-volume and SOLID.

Any chance you can contribute a test case in a PR then I can fill in the code?

@adamhathcock commented on GitHub (Nov 2, 2018): I guess I didn't cover the scenario of multi-volume and SOLID. Any chance you can contribute a test case in a PR then I can fill in the code?
Author
Owner

@adamhathcock commented on GitHub (Jul 1, 2020):

Fixed by https://github.com/adamhathcock/sharpcompress/pull/523

@adamhathcock commented on GitHub (Jul 1, 2020): Fixed by https://github.com/adamhathcock/sharpcompress/pull/523
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#328