Use streams instead of strings

This commit is contained in:
David
2020-12-23 19:24:58 +01:00
parent f38970cbd3
commit 2a574914ea
11 changed files with 24 additions and 30 deletions

View File

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