mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-02 21:24:15 -04:00
Add missing FileStreams
This commit is contained in:
parent
2a574914ea
commit
a714008b59
@ -341,7 +341,8 @@ namespace Emby.Server.Implementations.Channels
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using FileStream jsonStream = File.OpenRead(path);
|
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
|
catch
|
||||||
{
|
{
|
||||||
@ -810,8 +811,8 @@ namespace Emby.Server.Implementations.Channels
|
|||||||
{
|
{
|
||||||
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
|
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
|
||||||
{
|
{
|
||||||
var jsonString = await File.ReadAllTextAsync(cachePath, cancellationToken);
|
await using FileStream jsonStream = File.OpenRead(cachePath);
|
||||||
var cachedResult = JsonSerializer.Deserialize<ChannelItemResult>(jsonString);
|
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
if (cachedResult != null)
|
if (cachedResult != null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -833,8 +834,8 @@ namespace Emby.Server.Implementations.Channels
|
|||||||
{
|
{
|
||||||
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
|
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
|
||||||
{
|
{
|
||||||
var jsonString = await File.ReadAllTextAsync(cachePath, cancellationToken);
|
await using FileStream jsonStream = File.OpenRead(cachePath);
|
||||||
var cachedResult = JsonSerializer.Deserialize<ChannelItemResult>(jsonString);
|
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
if (cachedResult != null)
|
if (cachedResult != null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await using FileStream jsonStream = File.OpenRead(cacheFilePath);
|
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");
|
// _logger.LogDebug("Found cached media info");
|
||||||
}
|
}
|
||||||
@ -83,8 +83,8 @@ namespace Emby.Server.Implementations.Library
|
|||||||
if (cacheFilePath != null)
|
if (cacheFilePath != null)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
|
||||||
await using FileStream createStream = File.Create(cacheFilePath);
|
await using FileStream createStream = File.OpenWrite(cacheFilePath);
|
||||||
await JsonSerializer.SerializeAsync(createStream, mediaInfo, cancellationToken: cancellationToken).ConfigureAwait(false);
|
await JsonSerializer.SerializeAsync(createStream, mediaInfo, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
// _logger.LogDebug("Saved media info to {0}", cacheFilePath);
|
// _logger.LogDebug("Saved media info to {0}", cacheFilePath);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user