Fix sync disposal of async-created IAsyncDisposable objects (#14755)

This commit is contained in:
evan314159
2025-09-16 17:14:52 +08:00
committed by GitHub
parent 2ee887a502
commit 2618a5fba2
10 changed files with 256 additions and 111 deletions
@@ -169,7 +169,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
if (fileInfo.IsExternal)
{
using (var stream = await GetStream(fileInfo.Path, fileInfo.Protocol, cancellationToken).ConfigureAwait(false))
var stream = await GetStream(fileInfo.Path, fileInfo.Protocol, cancellationToken).ConfigureAwait(false);
await using (stream.ConfigureAwait(false))
{
var result = await CharsetDetector.DetectFromStreamAsync(stream, cancellationToken).ConfigureAwait(false);
var detected = result.Detected;
@@ -937,7 +938,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
.ConfigureAwait(false);
}
using (var stream = await GetStream(path, mediaSource.Protocol, cancellationToken).ConfigureAwait(false))
var stream = await GetStream(path, mediaSource.Protocol, cancellationToken).ConfigureAwait(false);
await using (stream.ConfigureAwait(false))
{
var result = await CharsetDetector.DetectFromStreamAsync(stream, cancellationToken).ConfigureAwait(false);
var charset = result.Detected?.EncodingName ?? string.Empty;