From 04d1a53d199bbf5fced102daae77b3ef0d64474d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 29 Dec 2013 12:07:29 -0500 Subject: don't persist lazy loaded paths --- .../ScheduledTasks/ScheduledTaskWorker.cs | 40 +++++++--------------- 1 file changed, 13 insertions(+), 27 deletions(-) (limited to 'MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs') diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 2406d0470..477dc4aee 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -121,7 +121,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks { LazyInitializer.EnsureInitialized(ref _lastExecutionResult, ref _lastExecutionResultinitialized, ref _lastExecutionResultSyncLock, () => { - var path = GetHistoryFilePath(false); + var path = GetHistoryFilePath(); try { @@ -432,43 +432,28 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks /// /// Gets the scheduled tasks configuration directory. /// - /// if set to true [create]. /// System.String. - private string GetScheduledTasksConfigurationDirectory(bool create) + private string GetScheduledTasksConfigurationDirectory() { - var path = Path.Combine(ApplicationPaths.ConfigurationDirectoryPath, "ScheduledTasks"); - - if (create) - { - Directory.CreateDirectory(path); - } - - return path; + return Path.Combine(ApplicationPaths.ConfigurationDirectoryPath, "ScheduledTasks"); } /// /// Gets the scheduled tasks data directory. /// - /// if set to true [create]. /// System.String. - private string GetScheduledTasksDataDirectory(bool create) + private string GetScheduledTasksDataDirectory() { - var path = Path.Combine(ApplicationPaths.DataPath, "ScheduledTasks"); - - if (create) - { - Directory.CreateDirectory(path); - } - return path; + return Path.Combine(ApplicationPaths.DataPath, "ScheduledTasks"); } /// /// Gets the history file path. /// /// The history file path. - private string GetHistoryFilePath(bool createDirectory) + private string GetHistoryFilePath() { - return Path.Combine(GetScheduledTasksDataDirectory(createDirectory), Id + ".js"); + return Path.Combine(GetScheduledTasksDataDirectory(), Id + ".js"); } /// @@ -477,7 +462,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks /// System.String. private string GetConfigurationFilePath() { - return Path.Combine(GetScheduledTasksConfigurationDirectory(false), Id + ".js"); + return Path.Combine(GetScheduledTasksConfigurationDirectory(), Id + ".js"); } /// @@ -512,9 +497,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks { var path = GetConfigurationFilePath(); - var parentPath = Path.GetDirectoryName(path); - - Directory.CreateDirectory(parentPath); + Directory.CreateDirectory(Path.GetDirectoryName(path)); JsonSerializer.SerializeToFile(triggers.Select(ScheduledTaskHelpers.GetTriggerInfo), path); } @@ -545,7 +528,10 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks result.ErrorMessage = ex.Message; } - JsonSerializer.SerializeToFile(result, GetHistoryFilePath(true)); + var path = GetHistoryFilePath(); + Directory.CreateDirectory(Path.GetDirectoryName(path)); + + JsonSerializer.SerializeToFile(result, path); LastExecutionResult = result; -- cgit v1.2.3