-
Notifications
You must be signed in to change notification settings - Fork 510
Writers should have async API #1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5f3031d
92c04a9
2dfe535
b5bd4cb
158460b
f766213
0d913f6
8d24dff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -133,14 +133,16 @@ await TarArchive.IsTarFileAsync(testStream, cancellationToken).ConfigureAwait(fa | |||||||||||||||||||||||||
| return new TarReader(sharpCompressStream, readerOptions, CompressionType.None); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public static ValueTask<IAsyncReader> OpenAsyncReader( | ||||||||||||||||||||||||||
| public static async ValueTask<IAsyncReader> OpenAsyncReader( | ||||||||||||||||||||||||||
| FileInfo fileInfo, | ||||||||||||||||||||||||||
| ReaderOptions? readerOptions = null, | ||||||||||||||||||||||||||
| CancellationToken cancellationToken = default | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| readerOptions ??= new ReaderOptions() { LeaveStreamOpen = false }; | ||||||||||||||||||||||||||
| return OpenAsyncReader(fileInfo.OpenRead(), readerOptions, cancellationToken); | ||||||||||||||||||||||||||
| var stream = fileInfo.OpenAsyncReadStream(cancellationToken); | ||||||||||||||||||||||||||
| return await OpenAsyncReader(stream, readerOptions, cancellationToken) | ||||||||||||||||||||||||||
| .ConfigureAwait(false); | ||||||||||||||||||||||||||
|
Comment on lines
+144
to
+145
|
||||||||||||||||||||||||||
| return await OpenAsyncReader(stream, readerOptions, cancellationToken) | |
| .ConfigureAwait(false); | |
| try | |
| { | |
| return await OpenAsyncReader(stream, readerOptions, cancellationToken) | |
| .ConfigureAwait(false); | |
| } | |
| catch | |
| { | |
| stream.Dispose(); | |
| throw; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,7 @@ | |||||
| <PropertyGroup Condition=" '$(TargetFramework)' == 'net48' Or '$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netstandard2.1' "> | ||||||
| <DefineConstants>$(DefineConstants);LEGACY_DOTNET</DefineConstants> | ||||||
| </PropertyGroup> | ||||||
| <PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net9.0' Or '$(TargetFramework)' == 'net10.0' "> | ||||||
| <PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0' "> | ||||||
|
||||||
| <PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0' "> | |
| <PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net9.0' Or '$(TargetFramework)' == 'net10.0' "> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stream opened from
fileInfo.OpenAsyncReadStream(...)is not disposed ifOpenAsyncReader(stream, ...)throws (e.g., invalid format). Wrap the call so the stream is disposed on failure to avoid file handle leaks.