diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-04-13 12:34:36 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-04-13 12:34:36 -0400 |
| commit | 47571bc5bdb32ae5d57e251af04b86d2fe8a2f62 (patch) | |
| tree | b6456ea71cdd94209f893ae24b2168e64c4a13eb /MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs | |
| parent | 26094af11522dfc100d709dcd9296805ba1e3fc7 (diff) | |
resolve scheduled task write error
Diffstat (limited to 'MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 78dcea493..c2551731f 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -121,12 +121,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks { if (_lastExecutionResult == null) { + var path = GetHistoryFilePath(); + lock (_lastExecutionResultSyncLock) { if (_lastExecutionResult == null) { - var path = GetHistoryFilePath(); - try { return JsonSerializer.DeserializeFromFile<TaskResult>(path); @@ -152,6 +152,14 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks private set { _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; } - var path = GetHistoryFilePath(); - Directory.CreateDirectory(Path.GetDirectoryName(path)); - - JsonSerializer.SerializeToFile(result, path); - LastExecutionResult = result; ((TaskManager)TaskManager).OnTaskCompleted(this, result); |
