Merge branch 'master' into startuptasks
This commit is contained in:
@@ -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();
|
||||
try
|
||||
{
|
||||
previouslyFailedImages = File.ReadAllText(failHistoryPath)
|
||||
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.ToList();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
previouslyFailedImages = new List<string>();
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
previouslyFailedImages = new List<string>();
|
||||
}
|
||||
catch (IOException)
|
||||
else
|
||||
{
|
||||
previouslyFailedImages = new List<string>();
|
||||
}
|
||||
@@ -136,11 +139,12 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
{
|
||||
previouslyFailedImages.Add(key);
|
||||
|
||||
var parentPath = _fileSystem.GetDirectoryName(failHistoryPath);
|
||||
var parentPath = Path.GetDirectoryName(failHistoryPath);
|
||||
|
||||
_fileSystem.CreateDirectory(parentPath);
|
||||
Directory.CreateDirectory(parentPath);
|
||||
|
||||
_fileSystem.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray()));
|
||||
string text = string.Join("|", previouslyFailedImages);
|
||||
File.WriteAllText(failHistoryPath, text);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
|
||||
@@ -128,21 +128,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;
|
||||
}
|
||||
@@ -155,7 +150,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
_lastExecutionResult = value;
|
||||
|
||||
var path = GetHistoryFilePath();
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
lock (_lastExecutionResultSyncLock)
|
||||
{
|
||||
@@ -531,28 +526,15 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
|
||||
private TaskTriggerInfo[] LoadTriggerSettings()
|
||||
{
|
||||
try
|
||||
string path = GetConfigurationFilePath();
|
||||
TaskTriggerInfo[] list = null;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var list = JsonSerializer.DeserializeFromFile<IEnumerable<TaskTriggerInfo>>(GetConfigurationFilePath());
|
||||
list = JsonSerializer.DeserializeFromFile<TaskTriggerInfo[]>(path);
|
||||
}
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// File doesn't exist. No biggie. Return defaults.
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
// File doesn't exist. No biggie. Return defaults.
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
return GetDefaultTriggers();
|
||||
// Return defaults if file doesn't exist.
|
||||
return list ?? GetDefaultTriggers();
|
||||
}
|
||||
|
||||
private TaskTriggerInfo[] GetDefaultTriggers()
|
||||
@@ -582,7 +564,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
{
|
||||
var path = GetConfigurationFilePath();
|
||||
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
JsonSerializer.SerializeToFile(triggers, path);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||
{
|
||||
try
|
||||
{
|
||||
_fileSystem.DeleteDirectory(directory, false);
|
||||
Directory.Delete(directory, false);
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user