Add missing FileStreams
This commit is contained in:
parent
2a574914ea
commit
a714008b59
|
@ -341,7 +341,8 @@ namespace Emby.Server.Implementations.Channels
|
|||
try
|
||||
{
|
||||
using FileStream jsonStream = File.OpenRead(path);
|
||||
return JsonSerializer.DeserializeAsync<List<MediaSourceInfo>>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
|
||||
return JsonSerializer.DeserializeAsync<List<MediaSourceInfo>>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult()
|
||||
?? new List<MediaSourceInfo>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -810,8 +811,8 @@ namespace Emby.Server.Implementations.Channels
|
|||
{
|
||||
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
|
||||
{
|
||||
var jsonString = await File.ReadAllTextAsync(cachePath, cancellationToken);
|
||||
var cachedResult = JsonSerializer.Deserialize<ChannelItemResult>(jsonString);
|
||||
await using FileStream jsonStream = File.OpenRead(cachePath);
|
||||
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
if (cachedResult != null)
|
||||
{
|
||||
return null;
|
||||
|
@ -833,8 +834,8 @@ namespace Emby.Server.Implementations.Channels
|
|||
{
|
||||
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
|
||||
{
|
||||
var jsonString = await File.ReadAllTextAsync(cachePath, cancellationToken);
|
||||
var cachedResult = JsonSerializer.Deserialize<ChannelItemResult>(jsonString);
|
||||
await using FileStream jsonStream = File.OpenRead(cachePath);
|
||||
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
if (cachedResult != null)
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Library
|
|||
try
|
||||
{
|
||||
await using FileStream jsonStream = File.OpenRead(cacheFilePath);
|
||||
await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
mediaInfo = await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// _logger.LogDebug("Found cached media info");
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ namespace Emby.Server.Implementations.Library
|
|||
if (cacheFilePath != null)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
|
||||
await using FileStream createStream = File.Create(cacheFilePath);
|
||||
await JsonSerializer.SerializeAsync(createStream, mediaInfo, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
await using FileStream createStream = File.OpenWrite(cacheFilePath);
|
||||
await JsonSerializer.SerializeAsync(createStream, mediaInfo, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// _logger.LogDebug("Saved media info to {0}", cacheFilePath);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user