Skip to content

Commit

Permalink
Merge pull request #848 from Morilli/fix-gzip-archivetype
Browse files Browse the repository at this point in the history
Fix gzip archives having a `Type` of `ArchiveType.Tar` instead of `ArchiveType.Gzip`
  • Loading branch information
adamhathcock committed Jun 6, 2024
2 parents bdb3a78 + 49f5cea commit 9061e92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/SharpCompress/Archives/GZip/GZipArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static GZipArchive Open(Stream stream, ReaderOptions? readerOptions = nul
/// </summary>
/// <param name="sourceStream"></param>
private GZipArchive(SourceStream sourceStream)
: base(ArchiveType.Tar, sourceStream) { }
: base(ArchiveType.GZip, sourceStream) { }

protected override IEnumerable<GZipVolume> LoadVolumes(SourceStream sourceStream)
{
Expand Down
11 changes: 10 additions & 1 deletion tests/SharpCompress.Test/GZip/GZipArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SharpCompress.Archives;
using SharpCompress.Archives.GZip;
using SharpCompress.Archives.Tar;
using SharpCompress.Common;
using Xunit;

namespace SharpCompress.Test.GZip;
Expand Down Expand Up @@ -106,7 +107,7 @@ public void GZip_Archive_Multiple_Reads()
}

[Fact]
public void TestGzCrcWithMostSignificaltBitNotNegative()
public void TestGzCrcWithMostSignificantBitNotNegative()
{
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"));
using var archive = GZipArchive.Open(stream);
Expand All @@ -116,4 +117,12 @@ public void TestGzCrcWithMostSignificaltBitNotNegative()
Assert.InRange(entry.Crc, 0L, 0xFFFFFFFFL);
}
}

[Fact]
public void TestGzArchiveTypeGzip()
{
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"));
using var archive = GZipArchive.Open(stream);
Assert.Equal(archive.Type, ArchiveType.GZip);
}
}

0 comments on commit 9061e92

Please sign in to comment.