mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-24 07:54:39 +00:00
Merge branch 'adam/async-creation' into copilot/sub-pr-1132
This commit is contained in:
@@ -195,7 +195,7 @@ public partial class SevenZipArchive
|
||||
var buffer = ArrayPool<byte>.Shared.Rent(6);
|
||||
try
|
||||
{
|
||||
if (!await stream.ReadFullyAsync(buffer, cancellationToken).ConfigureAwait(false))
|
||||
if (!await stream.ReadFullyAsync(buffer, 0, 6, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public static class ReaderFactory
|
||||
/// <param name="options"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static IAsyncReader OpenAsyncReader(
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
string filePath,
|
||||
ReaderOptions? options = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -47,7 +47,7 @@ public static class ReaderFactory
|
||||
/// <param name="options"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static IAsyncReader OpenAsyncReader(
|
||||
public static ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
FileInfo fileInfo,
|
||||
ReaderOptions? options = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -110,7 +110,7 @@ public static class ReaderFactory
|
||||
);
|
||||
}
|
||||
|
||||
public static IAsyncReader OpenAsyncReader(
|
||||
public static async ValueTask<IAsyncReader> OpenAsyncReader(
|
||||
Stream stream,
|
||||
ReaderOptions? options = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -136,7 +136,12 @@ public static class ReaderFactory
|
||||
if (testedFactory is IReaderFactory readerFactory)
|
||||
{
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
if (testedFactory.IsArchive(bStream))
|
||||
if (
|
||||
await testedFactory.IsArchiveAsync(
|
||||
bStream,
|
||||
cancellationToken: cancellationToken
|
||||
)
|
||||
)
|
||||
{
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
return readerFactory.OpenAsyncReader(bStream, options, cancellationToken);
|
||||
@@ -152,7 +157,10 @@ public static class ReaderFactory
|
||||
continue; // Already tested above
|
||||
}
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
if (factory is IReaderFactory readerFactory && factory.IsArchive(bStream))
|
||||
if (
|
||||
factory is IReaderFactory readerFactory
|
||||
&& await factory.IsArchiveAsync(bStream, cancellationToken: cancellationToken)
|
||||
)
|
||||
{
|
||||
((IStreamStack)bStream).StackSeek(pos);
|
||||
return readerFactory.OpenAsyncReader(bStream, options, cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user