aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
diff options
context:
space:
mode:
authordkanada <dkanada@users.noreply.github.com>2021-02-05 11:47:06 +0900
committerGitHub <noreply@github.com>2021-02-05 11:47:06 +0900
commit54a3ab15a38ff0f10a55398357538376958000e4 (patch)
tree1830eb490de1fc8d6589f920f4c8ffdbb68a4931 /Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
parent2e9661c415c362c694b6d63921ed71cf63b80b6f (diff)
parent1fdd2d6e0527a7b112ed6d79d8854f6fbe6fdaca (diff)
Merge pull request #5005 from jellyfin/bytes
JsonSerializer deserialize from bytes where possible
Diffstat (limited to 'Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs')
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs20
1 files changed, 10 insertions, 10 deletions
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index d3cf3bf3f..b302303f8 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -143,21 +143,21 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (File.Exists(path))
{
- try
+ var bytes = File.ReadAllBytes(path);
+ if (bytes.Length > 0)
{
- var jsonString = File.ReadAllText(path, Encoding.UTF8);
- if (!string.IsNullOrWhiteSpace(jsonString))
+ try
{
- _lastExecutionResult = JsonSerializer.Deserialize<TaskResult>(jsonString, _jsonOptions);
+ _lastExecutionResult = JsonSerializer.Deserialize<TaskResult>(bytes, _jsonOptions);
}
- else
+ catch (JsonException ex)
{
- _logger.LogDebug("Scheduled Task history file {Path} is empty. Skipping deserialization.", path);
+ _logger.LogError(ex, "Error deserializing {File}", path);
}
}
- catch (Exception ex)
+ else
{
- _logger.LogError(ex, "Error deserializing {File}", path);
+ _logger.LogDebug("Scheduled Task history file {Path} is empty. Skipping deserialization.", path);
}
}
@@ -541,8 +541,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
TaskTriggerInfo[] list = null;
if (File.Exists(path))
{
- var jsonString = File.ReadAllText(path, Encoding.UTF8);
- list = JsonSerializer.Deserialize<TaskTriggerInfo[]>(jsonString, _jsonOptions);
+ var bytes = File.ReadAllBytes(path);
+ list = JsonSerializer.Deserialize<TaskTriggerInfo[]>(bytes, _jsonOptions);
}
// Return defaults if file doesn't exist.