decompressing big .7z file throws error #748

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

Originally created by @DevOnBike on GitHub (Dec 24, 2025).

Originally assigned to: @adamhathcock, @Copilot on GitHub.

lib version 0.42.1
under .net 10

code:

public class SharpCompressExtractor : IArchiveExtractor
{
    public async Task<IReadOnlyCollection<FileInfo>> ExtractAsync(
        string archivePath,
        string destinationDirectory,
        CancellationToken token)
    {
        if (!File.Exists(archivePath))
        {
            throw new FileNotFoundException($"Nie znaleziono archiwum: {archivePath}");
        }

        var extractedFiles = new List<FileInfo>();

        using var archive = ArchiveFactory.Open(archivePath);

        foreach (var entry in archive.Entries)
        {
            if (entry.IsDirectory)
            {
                continue;
            }

            token.ThrowIfCancellationRequested();

            var targetPath = Path.Combine(destinationDirectory, entry.Key);

            var targetDir = Path.GetDirectoryName(targetPath);

            if (!string.IsNullOrEmpty(targetDir) && !Directory.Exists(targetDir))
            {
                Directory.CreateDirectory(targetDir);
            }

            using var sourceStream = await entry.OpenEntryStreamAsync(token);

            var fileOptions = new FileStreamOptions
            {
                Mode = FileMode.Create,
                Access = FileAccess.Write,
                Share = FileShare.None,
                BufferSize = 1_024 * 1_024,
                Options = FileOptions.Asynchronous
            };

            await using var targetStream = new FileStream(targetPath, fileOptions);

            await sourceStream.CopyToAsync(targetStream, token);

            var fileInfo = new FileInfo(targetPath);

            extractedFiles.Add(fileInfo);
        }

        return extractedFiles;
    }
}

usage

            try
            {
                var files = await fileExtractor.ExtractAsync(
    "C:\\whitelist\\20251223.7z",
    "c:/whitelist/out",
    CancellationToken.None);
            }
            catch (Exception ex)
            {
                
            }

Data Error

at SharpCompress.Compressors.LZMA.LzmaStream.d__52.MoveNext()
at SharpCompress.Compressors.LZMA.LzmaStream.d__56.MoveNext()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
at SharpCompress.IO.ReadOnlySubStream.d__24.MoveNext()
at System.IO.Stream.<g__Core|30_0>d.MoveNext()
at SharpCompressExtractor.d__0.MoveNext() in SharpCompressExtractor.cs

file : probably any from https://www.podatki.gov.pl/narzedzia/white-list/

but for sure exist for this url: https://plikplaski.mf.gov.pl/pliki//20251223.7z

this file perfectly uncompress under win11 using native extractor or 7zip manager

Originally created by @DevOnBike on GitHub (Dec 24, 2025). Originally assigned to: @adamhathcock, @Copilot on GitHub. lib version 0.42.1 under .net 10 code: ``` public class SharpCompressExtractor : IArchiveExtractor { public async Task<IReadOnlyCollection<FileInfo>> ExtractAsync( string archivePath, string destinationDirectory, CancellationToken token) { if (!File.Exists(archivePath)) { throw new FileNotFoundException($"Nie znaleziono archiwum: {archivePath}"); } var extractedFiles = new List<FileInfo>(); using var archive = ArchiveFactory.Open(archivePath); foreach (var entry in archive.Entries) { if (entry.IsDirectory) { continue; } token.ThrowIfCancellationRequested(); var targetPath = Path.Combine(destinationDirectory, entry.Key); var targetDir = Path.GetDirectoryName(targetPath); if (!string.IsNullOrEmpty(targetDir) && !Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } using var sourceStream = await entry.OpenEntryStreamAsync(token); var fileOptions = new FileStreamOptions { Mode = FileMode.Create, Access = FileAccess.Write, Share = FileShare.None, BufferSize = 1_024 * 1_024, Options = FileOptions.Asynchronous }; await using var targetStream = new FileStream(targetPath, fileOptions); await sourceStream.CopyToAsync(targetStream, token); var fileInfo = new FileInfo(targetPath); extractedFiles.Add(fileInfo); } return extractedFiles; } } ``` usage ``` try { var files = await fileExtractor.ExtractAsync( "C:\\whitelist\\20251223.7z", "c:/whitelist/out", CancellationToken.None); } catch (Exception ex) { } ``` Data Error at SharpCompress.Compressors.LZMA.LzmaStream.<DecodeChunkHeaderAsync>d__52.MoveNext() at SharpCompress.Compressors.LZMA.LzmaStream.<ReadAsync>d__56.MoveNext() at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult() at SharpCompress.IO.ReadOnlySubStream.<ReadAsync>d__24.MoveNext() at System.IO.Stream.<<CopyToAsync>g__Core|30_0>d.MoveNext() at SharpCompressExtractor.<ExtractAsync>d__0.MoveNext() in SharpCompressExtractor.cs file : probably any from https://www.podatki.gov.pl/narzedzia/white-list/ but for sure exist for this url: https://plikplaski.mf.gov.pl/pliki//20251223.7z this file perfectly uncompress under win11 using native extractor or 7zip manager
claunia added the bug label 2026-01-29 22:16: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#748