mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 06:54:40 +00:00
fixes found by gh and sol
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user