mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-18 15:03:06 +03:00
Multiple Stream changes
* Remove useless MemoryStream in DlnaHttpClient * Use HttpContent.ReadFromJsonAsync extension * Call ConfigureAwait for IAsyncDisposable * Use HttpContent.CopyToAsync where possible
This commit is contained in:
@@ -386,11 +386,11 @@ namespace Emby.Server.Implementations.Plugins
|
||||
var url = new Uri(packageInfo.ImageUrl);
|
||||
imagePath = Path.Join(path, url.Segments[^1]);
|
||||
|
||||
await using var fileStream = AsyncFile.OpenWrite(imagePath);
|
||||
|
||||
var fileStream = AsyncFile.OpenWrite(imagePath);
|
||||
Stream? downloadStream = null;
|
||||
try
|
||||
{
|
||||
await using var downloadStream = await HttpClientFactory
|
||||
downloadStream = await HttpClientFactory
|
||||
.CreateClient(NamedClient.Default)
|
||||
.GetStreamAsync(url)
|
||||
.ConfigureAwait(false);
|
||||
@@ -402,6 +402,14 @@ namespace Emby.Server.Implementations.Plugins
|
||||
_logger.LogError(ex, "Failed to download image to path {Path} on disk.", imagePath);
|
||||
imagePath = string.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
await fileStream.DisposeAsync().ConfigureAwait(false);
|
||||
if (downloadStream is not null)
|
||||
{
|
||||
await downloadStream.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var manifest = new PluginManifest
|
||||
@@ -421,7 +429,7 @@ namespace Emby.Server.Implementations.Plugins
|
||||
ImagePath = imagePath
|
||||
};
|
||||
|
||||
if (!await ReconcileManifest(manifest, path))
|
||||
if (!await ReconcileManifest(manifest, path).ConfigureAwait(false))
|
||||
{
|
||||
// An error occurred during reconciliation and saving could be undesirable.
|
||||
return false;
|
||||
@@ -458,7 +466,7 @@ namespace Emby.Server.Implementations.Plugins
|
||||
}
|
||||
|
||||
using var metaStream = File.OpenRead(metafile);
|
||||
var localManifest = await JsonSerializer.DeserializeAsync<PluginManifest>(metaStream, _jsonOptions);
|
||||
var localManifest = await JsonSerializer.DeserializeAsync<PluginManifest>(metaStream, _jsonOptions).ConfigureAwait(false);
|
||||
localManifest ??= new PluginManifest();
|
||||
|
||||
if (!Equals(localManifest.Id, manifest.Id))
|
||||
|
||||
Reference in New Issue
Block a user