diff --git a/MediaBrowser.Common/Configuration/ApplicationPaths.cs b/MediaBrowser.Common/Configuration/ApplicationPaths.cs index 1e1ecd85a1..7fb1684d1a 100644 --- a/MediaBrowser.Common/Configuration/ApplicationPaths.cs +++ b/MediaBrowser.Common/Configuration/ApplicationPaths.cs @@ -24,37 +24,13 @@ namespace MediaBrowser.Common.Configuration if (_programDataPath == null) { _programDataPath = GetProgramDataPath(); - InitDirectories(); //move this here so we don't have to check for existence on every directory reference } return _programDataPath; } } - private static void InitDirectories() - { - if (!Directory.Exists(LogDirectoryPath)) - { - Directory.CreateDirectory(LogDirectoryPath); - } - if (!Directory.Exists(PluginsPath)) - { - Directory.CreateDirectory(PluginsPath); - } - if (!Directory.Exists(RootFolderPath)) - { - Directory.CreateDirectory(RootFolderPath); - } - if (!Directory.Exists(ConfigurationPath)) - { - Directory.CreateDirectory(ConfigurationPath); - Directory.CreateDirectory(SystemConfigurationPath); - Directory.CreateDirectory(DeviceConfigurationPath); - Directory.CreateDirectory(UserConfigurationPath); - } - - - } + private static string _pluginsPath; /// /// Gets the path to the plugin directory /// @@ -62,10 +38,20 @@ namespace MediaBrowser.Common.Configuration { get { - return Path.Combine(ProgramDataPath, "plugins"); + if (_pluginsPath == null) + { + _pluginsPath = Path.Combine(ProgramDataPath, "plugins"); + if (!Directory.Exists(PluginsPath)) + { + Directory.CreateDirectory(PluginsPath); + } + } + + return _pluginsPath; } } + private static string _configurationPath; /// /// Gets the path to the application configuration root directory /// @@ -73,10 +59,19 @@ namespace MediaBrowser.Common.Configuration { get { - return Path.Combine(ProgramDataPath, "config"); + if (_configurationPath == null) + { + _configurationPath = Path.Combine(ProgramDataPath, "config"); + if (!Directory.Exists(ConfigurationPath)) + { + Directory.CreateDirectory(ConfigurationPath); + } + } + return _configurationPath; } } + private static string _systemConfigurationPath; /// /// Gets the path to the system configuration directory /// @@ -84,10 +79,19 @@ namespace MediaBrowser.Common.Configuration { get { - return Path.Combine(ConfigurationPath, "system"); + if (_systemConfigurationPath == null) + { + _systemConfigurationPath = Path.Combine(ConfigurationPath, "system"); + if (!Directory.Exists(_systemConfigurationPath)) + { + Directory.CreateDirectory(_systemConfigurationPath); + } + } + return _systemConfigurationPath; } } + private static string _userConfigurationPath; /// /// Gets the path to the user configuration directory /// @@ -95,10 +99,19 @@ namespace MediaBrowser.Common.Configuration { get { - return Path.Combine(ConfigurationPath, "user"); + if (_userConfigurationPath == null) + { + _userConfigurationPath = Path.Combine(ConfigurationPath, "user"); + if (!Directory.Exists(_userConfigurationPath)) + { + Directory.CreateDirectory(_userConfigurationPath); + } + } + return _userConfigurationPath; } } + private static string _deviceConfigurationPath; /// /// Gets the path to the device configuration directory /// @@ -106,10 +119,19 @@ namespace MediaBrowser.Common.Configuration { get { - return Path.Combine(ConfigurationPath, "device"); + if (_deviceConfigurationPath == null) + { + _deviceConfigurationPath = Path.Combine(ConfigurationPath, "device"); + if (!Directory.Exists(_deviceConfigurationPath)) + { + Directory.CreateDirectory(_deviceConfigurationPath); + } + } + return _deviceConfigurationPath; } } + private static string _logDirectoryPath; /// /// Gets the path to the log directory /// @@ -117,10 +139,19 @@ namespace MediaBrowser.Common.Configuration { get { - return Path.Combine(ProgramDataPath, "logs"); + if (_logDirectoryPath == null) + { + _logDirectoryPath = Path.Combine(ProgramDataPath, "logs"); + if (!Directory.Exists(_logDirectoryPath)) + { + Directory.CreateDirectory(_logDirectoryPath); + } + } + return _logDirectoryPath; } } + private static string _rootFolderPath; /// /// Gets the path to the root media directory /// @@ -128,7 +159,15 @@ namespace MediaBrowser.Common.Configuration { get { - return Path.Combine(ProgramDataPath, "root"); + if (_rootFolderPath == null) + { + _rootFolderPath = Path.Combine(ProgramDataPath, "root"); + if (!Directory.Exists(_rootFolderPath)) + { + Directory.CreateDirectory(_rootFolderPath); + } + } + return _rootFolderPath; } }