aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ScheduledTasks
diff options
context:
space:
mode:
authorAndrew Rabert <6550543+nvllsvm@users.noreply.github.com>2019-01-27 14:04:39 -0500
committerGitHub <noreply@github.com>2019-01-27 14:04:39 -0500
commitb4893b9ac90ea19eb65888d87e73ca260067a999 (patch)
treed5d25a931f68c748bec8fd88085a3c4dff0d270d /Emby.Server.Implementations/ScheduledTasks
parentb0608d26b492b07f22ed745a7077975da733a780 (diff)
parentffe79c89829fb232e8ccb4ae4caf4b732ce51600 (diff)
Merge pull request #740 from Bond-009/deadcode
Remove code for pre-installed plugins & properly check if file exists
Diffstat (limited to 'Emby.Server.Implementations/ScheduledTasks')
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs21
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs47
2 files changed, 27 insertions, 41 deletions
diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
index 0ae7ae96c..57bc61c7a 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
@@ -101,17 +101,20 @@ namespace Emby.Server.Implementations.ScheduledTasks
List<string> previouslyFailedImages;
- try
+ if (File.Exists(failHistoryPath))
{
- previouslyFailedImages = _fileSystem.ReadAllText(failHistoryPath)
- .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- }
- catch (FileNotFoundException)
- {
- previouslyFailedImages = new List<string>();
+ try
+ {
+ previouslyFailedImages = _fileSystem.ReadAllText(failHistoryPath)
+ .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
+ .ToList();
+ }
+ catch (IOException)
+ {
+ previouslyFailedImages = new List<string>();
+ }
}
- catch (IOException)
+ else
{
previouslyFailedImages = new List<string>();
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 93a9a0d81..88b3dd07f 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -129,21 +129,16 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
if (_lastExecutionResult == null && !_readFromFile)
{
- try
+ if (File.Exists(path))
{
- _lastExecutionResult = JsonSerializer.DeserializeFromFile<TaskResult>(path);
- }
- catch (DirectoryNotFoundException)
- {
- // File doesn't exist. No biggie
- }
- catch (FileNotFoundException)
- {
- // File doesn't exist. No biggie
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error deserializing {path}", path);
+ try
+ {
+ _lastExecutionResult = JsonSerializer.DeserializeFromFile<TaskResult>(path);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex, "Error deserializing {File}", path);
+ }
}
_readFromFile = true;
}
@@ -532,28 +527,16 @@ namespace Emby.Server.Implementations.ScheduledTasks
private TaskTriggerInfo[] LoadTriggerSettings()
{
- try
- {
- var list = JsonSerializer.DeserializeFromFile<IEnumerable<TaskTriggerInfo>>(GetConfigurationFilePath());
-
- if (list != null)
- {
- return list.ToArray();
- }
- }
- catch (FileNotFoundException)
- {
- // File doesn't exist. No biggie. Return defaults.
- }
- catch (DirectoryNotFoundException)
+ string path = GetConfigurationFilePath();
+ if (!File.Exists(path))
{
// File doesn't exist. No biggie. Return defaults.
+ GetDefaultTriggers();
}
- catch
- {
- }
- return GetDefaultTriggers();
+ var list = JsonSerializer.DeserializeFromFile<TaskTriggerInfo[]>(path);
+
+ return list ?? GetDefaultTriggers();
}
private TaskTriggerInfo[] GetDefaultTriggers()