mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
Compare commits
3 Commits
0.44.0
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b83ee67cdc | ||
|
|
bfb8e9421e | ||
|
|
27e6051241 |
@@ -144,7 +144,7 @@ public abstract class AbstractArchive<TEntry, TVolume> : IArchive, IArchiveExtra
|
||||
/// <returns></returns>
|
||||
public IReader ExtractAllEntries()
|
||||
{
|
||||
if (!IsSolid && Type != ArchiveType.SevenZip)
|
||||
if (!IsSolid && Type != ArchiveType.SevenZip && Type != ArchiveType.Tar)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"ExtractAllEntries can only be used on solid archives or 7Zip archives (which require random access)."
|
||||
|
||||
@@ -295,4 +295,28 @@ public class TarArchiveTests : ArchiveTests
|
||||
|
||||
Assert.False(isTar);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tar_ExtractAllEntries_ReadsAllEntries()
|
||||
{
|
||||
// Tests that ExtractAllEntries correctly iterates through all entries
|
||||
// This is a regression test for issue #1029
|
||||
var archiveFullPath = Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar");
|
||||
using var archive = TarArchive.Open(archiveFullPath);
|
||||
using var reader = archive.ExtractAllEntries();
|
||||
|
||||
var readEntries = 0;
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
readEntries++;
|
||||
|
||||
if (reader.Entry.IsDirectory)
|
||||
continue;
|
||||
|
||||
using var ms = new MemoryStream();
|
||||
reader.WriteEntryTo(ms);
|
||||
}
|
||||
|
||||
Assert.Equal(archive.Entries.Count, readEntries);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user