From 3488cfecbd54eaaf917d853664f68cac84d472e9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 29 Dec 2013 09:12:29 -0500 Subject: make lazy loaded paths more nimble --- .../BaseApplicationPaths.cs | 44 ++-------------------- .../Logging/NlogManager.cs | 2 + .../Updates/InstallationManager.cs | 1 + 3 files changed, 7 insertions(+), 40 deletions(-) (limited to 'MediaBrowser.Common.Implementations') diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs index eba8f5698..213942c9d 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs @@ -92,10 +92,6 @@ namespace MediaBrowser.Common.Implementations } } - /// - /// The _plugins path - /// - private string _pluginsPath; /// /// Gets the path to the plugin directory /// @@ -104,20 +100,10 @@ namespace MediaBrowser.Common.Implementations { get { - if (_pluginsPath == null) - { - _pluginsPath = Path.Combine(ProgramDataPath, "plugins"); - Directory.CreateDirectory(_pluginsPath); - } - - return _pluginsPath; + return Path.Combine(ProgramDataPath, "plugins"); } } - /// - /// The _plugin configurations path - /// - private string _pluginConfigurationsPath; /// /// Gets the path to the plugin configurations directory /// @@ -126,17 +112,10 @@ namespace MediaBrowser.Common.Implementations { get { - if (_pluginConfigurationsPath == null) - { - _pluginConfigurationsPath = Path.Combine(PluginsPath, "configurations"); - Directory.CreateDirectory(_pluginConfigurationsPath); - } - - return _pluginConfigurationsPath; + return Path.Combine(PluginsPath, "configurations"); } } - private string _tempUpdatePath; /// /// Gets the path to where temporary update files will be stored /// @@ -145,20 +124,10 @@ namespace MediaBrowser.Common.Implementations { get { - if (_tempUpdatePath == null) - { - _tempUpdatePath = Path.Combine(ProgramDataPath, "updates"); - Directory.CreateDirectory(_tempUpdatePath); - } - - return _tempUpdatePath; + return Path.Combine(ProgramDataPath, "updates"); } } - /// - /// The _log directory path - /// - private string _logDirectoryPath; /// /// Gets the path to the log directory /// @@ -167,12 +136,7 @@ namespace MediaBrowser.Common.Implementations { get { - if (_logDirectoryPath == null) - { - _logDirectoryPath = Path.Combine(ProgramDataPath, "logs"); - Directory.CreateDirectory(_logDirectoryPath); - } - return _logDirectoryPath; + return Path.Combine(ProgramDataPath, "logs"); } } diff --git a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs index 56f2b5e29..fb7fd1698 100644 --- a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs +++ b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs @@ -186,6 +186,8 @@ namespace MediaBrowser.Common.Implementations.Logging { LogFilePath = Path.Combine(LogDirectory, LogFilePrefix + "-" + decimal.Round(DateTime.Now.Ticks / 10000000) + ".log"); + Directory.CreateDirectory(Path.GetDirectoryName(LogFilePath)); + AddFileTarget(LogFilePath, level); LogSeverity = level; diff --git a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs index 0581343d3..18462ba9b 100644 --- a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs +++ b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs @@ -528,6 +528,7 @@ namespace MediaBrowser.Common.Implementations.Updates // Success - move it to the real target try { + Directory.CreateDirectory(Path.GetDirectoryName(target)); File.Copy(tempFile, target, true); //If it is an archive - write out a version file so we know what it is if (isArchive) -- cgit v1.2.3