Fix crash when trying to deserialize a non-existing scheduled task

This commit is contained in:
Claus Vium 2019-01-27 20:18:51 +01:00 committed by Bond-009
parent b4893b9ac9
commit a05d803d4c
1 changed files with 4 additions and 5 deletions

View File

@ -528,14 +528,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
private TaskTriggerInfo[] LoadTriggerSettings() private TaskTriggerInfo[] LoadTriggerSettings()
{ {
string path = GetConfigurationFilePath(); string path = GetConfigurationFilePath();
if (!File.Exists(path)) TaskTriggerInfo[] list = null;
if (File.Exists(path))
{ {
// File doesn't exist. No biggie. Return defaults. list = JsonSerializer.DeserializeFromFile<TaskTriggerInfo[]>(path);
GetDefaultTriggers();
} }
var list = JsonSerializer.DeserializeFromFile<TaskTriggerInfo[]>(path); // Return defaults if file doesn't exist.
return list ?? GetDefaultTriggers(); return list ?? GetDefaultTriggers();
} }