ITADN

Unable to decompress compressed tar files with ArchiveFactory.OpenArchive

#1276Opendoxxx 创建于 2026-04-06
D
doxxxcommented
Using SharpCompress 0.47.4, when trying to decompress a gnu tar file compressed using gzip, bzip2 or zstd, I get the following error after the second entry: ``` dir size=0 compressed=0 path=./ file size=4149673 compressed=4149673 path=./GHT00710.jpg SharpCompress.Common.IncompleteArchiveException: Failed to read TAR header at SharpCompress.Archives.Tar.TarArchive.LoadEntries(IEnumerable`1 volumes)+MoveNext() in D:\a\sharpcompress\sharpcompress\src\SharpCompress\Archives\Tar\TarArchive.cs:line 179 at SharpCompress.LazyReadOnlyCollection`1.LazyLoader.MoveNext() in D:\a\sharpcompress\sharpcompress\src\SharpCompress\LazyReadOnlyCollection.cs:line 53 ``` If I use the same test code against an uncompressed tar file, it works fine. Test code: ``` using var stream = File.OpenRead(archivePath); using var archive = ArchiveFactory.OpenArchive(stream); foreach (var entry in archive.Entries) { var entryType = entry.IsDirectory ? "dir " : "file"; var key = string.IsNullOrWhiteSpace(entry.Key) ? "<no-name>" : entry.Key; Console.WriteLine( $"{entryType} size={entry.Size} compressed={entry.CompressedSize} path={key}"); } ```
2 条评论