mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 09:34:44 +01:00
Use streams instead of strings
This commit is contained in:
@@ -1038,6 +1038,7 @@ namespace Emby.Server.Implementations
|
||||
}
|
||||
|
||||
var directories = Directory.EnumerateDirectories(path, "*.*", SearchOption.TopDirectoryOnly);
|
||||
var jsonOptions = JsonDefaults.GetOptions();
|
||||
|
||||
foreach (var dir in directories)
|
||||
{
|
||||
@@ -1046,8 +1047,8 @@ namespace Emby.Server.Implementations
|
||||
var metafile = Path.Combine(dir, "meta.json");
|
||||
if (File.Exists(metafile))
|
||||
{
|
||||
var jsonString = File.ReadAllText(metafile);
|
||||
var manifest = JsonSerializer.Deserialize<PluginManifest>(jsonString, JsonDefaults.GetOptions());
|
||||
using FileStream jsonStream = File.OpenRead(metafile);
|
||||
var manifest = JsonSerializer.DeserializeAsync<PluginManifest>(jsonStream, jsonOptions).GetAwaiter().GetResult();
|
||||
|
||||
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
|
||||
{
|
||||
|
||||
@@ -340,8 +340,8 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
try
|
||||
{
|
||||
var jsonString = File.ReadAllText(path);
|
||||
return JsonSerializer.Deserialize<List<MediaSourceInfo>>(jsonString, JsonDefaults.GetOptions()) ?? new List<MediaSourceInfo>();
|
||||
using FileStream jsonStream = File.OpenRead(path);
|
||||
return JsonSerializer.DeserializeAsync<List<MediaSourceInfo>>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
var jsonString = await File.ReadAllTextAsync(cacheFilePath, cancellationToken).ConfigureAwait(false);
|
||||
JsonSerializer.Deserialize<MediaInfo>(jsonString, JsonDefaults.GetOptions());
|
||||
await using FileStream jsonStream = File.OpenRead(cacheFilePath);
|
||||
await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// _logger.LogDebug("Found cached media info");
|
||||
}
|
||||
|
||||
@@ -641,8 +641,8 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = await File.ReadAllTextAsync(cacheFilePath, cancellationToken).ConfigureAwait(false);
|
||||
mediaInfo = JsonSerializer.Deserialize<MediaInfo>(json, JsonDefaults.GetOptions());
|
||||
await using FileStream jsonStream = File.OpenRead(cacheFilePath);
|
||||
mediaInfo = await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// _logger.LogDebug("Found cached media info");
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText(_dataPath);
|
||||
_items = JsonSerializer.Deserialize<T[]>(json, JsonDefaults.GetOptions());
|
||||
using FileStream jsonStream = File.OpenRead(_dataPath);
|
||||
_items = JsonSerializer.DeserializeAsync<T[]>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -139,15 +139,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
{
|
||||
try
|
||||
{
|
||||
var jsonString = File.ReadAllText(path);
|
||||
if (!string.IsNullOrWhiteSpace(jsonString))
|
||||
{
|
||||
_lastExecutionResult = JsonSerializer.Deserialize<TaskResult>(jsonString, JsonDefaults.GetOptions());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogDebug("Scheduled Task history file {path} is empty. Skipping deserialization.", path);
|
||||
}
|
||||
using FileStream jsonStream = File.OpenRead(path);
|
||||
_lastExecutionResult = JsonSerializer.DeserializeAsync<TaskResult>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user