aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Channels/ChannelManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Channels/ChannelManager.cs')
-rw-r--r--Emby.Server.Implementations/Channels/ChannelManager.cs35
1 files changed, 24 insertions, 11 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs
index 8279acb05..c505e8fe1 100644
--- a/Emby.Server.Implementations/Channels/ChannelManager.cs
+++ b/Emby.Server.Implementations/Channels/ChannelManager.cs
@@ -812,11 +812,16 @@ namespace Emby.Server.Implementations.Channels
{
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
{
- await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
- var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (cachedResult is not null)
+ var jsonStream = AsyncFile.OpenRead(cachePath);
+ await using (jsonStream.ConfigureAwait(false))
{
- return null;
+ var cachedResult = await JsonSerializer
+ .DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken)
+ .ConfigureAwait(false);
+ if (cachedResult is not null)
+ {
+ return null;
+ }
}
}
}
@@ -835,11 +840,16 @@ namespace Emby.Server.Implementations.Channels
{
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
{
- await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
- var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (cachedResult is not null)
+ var jsonStream = AsyncFile.OpenRead(cachePath);
+ await using (jsonStream.ConfigureAwait(false))
{
- return null;
+ var cachedResult = await JsonSerializer
+ .DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken)
+ .ConfigureAwait(false);
+ if (cachedResult is not null)
+ {
+ return null;
+ }
}
}
}
@@ -867,7 +877,7 @@ namespace Emby.Server.Implementations.Channels
throw new InvalidOperationException("Channel returned a null result from GetChannelItems");
}
- await CacheResponse(result, cachePath);
+ await CacheResponse(result, cachePath).ConfigureAwait(false);
return result;
}
@@ -883,8 +893,11 @@ namespace Emby.Server.Implementations.Channels
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
- await using FileStream createStream = File.Create(path);
- await JsonSerializer.SerializeAsync(createStream, result, _jsonOptions).ConfigureAwait(false);
+ var createStream = File.Create(path);
+ await using (createStream.ConfigureAwait(false))
+ {
+ await JsonSerializer.SerializeAsync(createStream, result, _jsonOptions).ConfigureAwait(false);
+ }
}
catch (Exception ex)
{