resolve scheduled task write error

This commit is contained in:
Luke Pulverenti 2015-04-13 12:34:36 -04:00
parent 26094af115
commit 47571bc5bd

View File

@ -121,12 +121,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{ {
if (_lastExecutionResult == null) if (_lastExecutionResult == null)
{ {
var path = GetHistoryFilePath();
lock (_lastExecutionResultSyncLock) lock (_lastExecutionResultSyncLock)
{ {
if (_lastExecutionResult == null) if (_lastExecutionResult == null)
{ {
var path = GetHistoryFilePath();
try try
{ {
return JsonSerializer.DeserializeFromFile<TaskResult>(path); return JsonSerializer.DeserializeFromFile<TaskResult>(path);
@ -152,6 +152,14 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
private set private set
{ {
_lastExecutionResult = value; _lastExecutionResult = value;
var path = GetHistoryFilePath();
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_lastExecutionResultSyncLock)
{
JsonSerializer.SerializeToFile(value, path);
}
} }
} }
@ -582,11 +590,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
result.LongErrorMessage = ex.StackTrace; result.LongErrorMessage = ex.StackTrace;
} }
var path = GetHistoryFilePath();
Directory.CreateDirectory(Path.GetDirectoryName(path));
JsonSerializer.SerializeToFile(result, path);
LastExecutionResult = result; LastExecutionResult = result;
((TaskManager)TaskManager).OnTaskCompleted(this, result); ((TaskManager)TaskManager).OnTaskCompleted(this, result);