|
@@ -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)
|
|
|
{
|