mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
IAsyncDisposable is one big pitfall
https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-disposeasync#unacceptable-pattern Regex used: ``` await using \(.+\) \W+await using ```
This commit is contained in:
parent
77c73e241f
commit
754bda8f73
@ -545,14 +545,16 @@ namespace Jellyfin.Server
|
|||||||
const string ResourcePath = "Jellyfin.Server.Resources.Configuration.logging.json";
|
const string ResourcePath = "Jellyfin.Server.Resources.Configuration.logging.json";
|
||||||
Stream resource = typeof(Program).Assembly.GetManifestResourceStream(ResourcePath)
|
Stream resource = typeof(Program).Assembly.GetManifestResourceStream(ResourcePath)
|
||||||
?? throw new InvalidOperationException($"Invalid resource path: '{ResourcePath}'");
|
?? throw new InvalidOperationException($"Invalid resource path: '{ResourcePath}'");
|
||||||
Stream dst = new FileStream(configPath, FileMode.CreateNew, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
|
||||||
await using (resource.ConfigureAwait(false))
|
await using (resource.ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
Stream dst = new FileStream(configPath, FileMode.CreateNew, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||||
await using (dst.ConfigureAwait(false))
|
await using (dst.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
// Copy the resource contents to the expected file path for the config file
|
// Copy the resource contents to the expected file path for the config file
|
||||||
await resource.CopyToAsync(dst).ConfigureAwait(false);
|
await resource.CopyToAsync(dst).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the application configuration.
|
/// Create the application configuration.
|
||||||
|
@ -681,14 +681,16 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
if (!string.Equals(text, newText, StringComparison.Ordinal))
|
if (!string.Equals(text, newText, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||||
var writer = new StreamWriter(fileStream, encoding);
|
|
||||||
await using (fileStream.ConfigureAwait(false))
|
await using (fileStream.ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
var writer = new StreamWriter(fileStream, encoding);
|
||||||
await using (writer.ConfigureAwait(false))
|
await using (writer.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
await writer.WriteAsync(newText.AsMemory(), cancellationToken).ConfigureAwait(false);
|
await writer.WriteAsync(newText.AsMemory(), cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string GetSubtitleCachePath(MediaSourceInfo mediaSource, int subtitleStreamIndex, string outputSubtitleExtension)
|
private string GetSubtitleCachePath(MediaSourceInfo mediaSource, int subtitleStreamIndex, string outputSubtitleExtension)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user