fixes found by gh and sol

This commit is contained in:
Adam Hathcock
2026-08-03 16:38:27 +01:00
parent d391cf21e1
commit 4a71ec898b
4 changed files with 67 additions and 14 deletions

View File

@@ -185,14 +185,25 @@ public class GZipFactory
}
sharpCompressStream.Rewind();
var tarReader = await new TarFactory()
.TryOpenReaderAsync(sharpCompressStream, options, cancellationToken)
using var testStream = SharpCompressStream.CreateNonDisposing(
await options
.Providers.CreateDecompressStreamAsync(
CompressionType.GZip,
SharpCompressStream.CreateNonDisposing(sharpCompressStream),
CompressionContext.FromStream(sharpCompressStream).WithReaderOptions(options),
cancellationToken
)
.ConfigureAwait(false)
);
var isTarArchive = await TarArchive
.IsTarFileAsync(testStream, cancellationToken)
.ConfigureAwait(false);
sharpCompressStream.Rewind();
sharpCompressStream.StopRecording();
if (tarReader is not null)
if (isTarArchive)
{
return tarReader;
return new TarReader(sharpCompressStream, options, CompressionType.GZip);
}
return await OpenAsyncReader(sharpCompressStream, options, cancellationToken)

View File

@@ -100,14 +100,24 @@ public class LzwFactory : Factory, IReaderFactory
}
sharpCompressStream.Rewind();
var tarReader = await new TarFactory()
.TryOpenReaderAsync(sharpCompressStream, options, cancellationToken)
using var testStream = SharpCompressStream.CreateNonDisposing(
await options
.Providers.CreateDecompressStreamAsync(
CompressionType.Lzw,
SharpCompressStream.CreateNonDisposing(sharpCompressStream),
cancellationToken
)
.ConfigureAwait(false)
);
var isTarArchive = await TarArchive
.IsTarFileAsync(testStream, cancellationToken)
.ConfigureAwait(false);
sharpCompressStream.Rewind();
sharpCompressStream.StopRecording();
if (tarReader is not null)
if (isTarArchive)
{
return tarReader;
return new TarReader(sharpCompressStream, options, CompressionType.Lzw);
}
return await OpenAsyncReader(sharpCompressStream, options, cancellationToken)