diff options
| author | Bond-009 <bond.009@outlook.com> | 2019-02-16 17:03:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-16 17:03:15 +0100 |
| commit | bdfd042d705ec25ef37516ea7495f71eaee53d2e (patch) | |
| tree | 463809b0be8f2a8995ca7648f2425d19c3bfa8a7 /Emby.Server.Implementations/AppBase | |
| parent | a6a4cd5667fbb5a793cb9e551ce9c9a9bfb0d44b (diff) | |
| parent | 25c2267a89af5c2e82774c638cdad0defcc894b5 (diff) | |
Merge branch 'master' into fields
Diffstat (limited to 'Emby.Server.Implementations/AppBase')
| -rw-r--r-- | Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs | 103 | ||||
| -rw-r--r-- | Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs | 19 |
2 files changed, 37 insertions, 85 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs index 701c04f9e..f26cc4f62 100644 --- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs +++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using MediaBrowser.Common.Configuration; @@ -14,50 +15,44 @@ namespace Emby.Server.Implementations.AppBase /// </summary> protected BaseApplicationPaths( string programDataPath, - string appFolderPath, - string logDirectoryPath = null, - string configurationDirectoryPath = null, - string cacheDirectoryPath = null) + string logDirectoryPath, + string configurationDirectoryPath, + string cacheDirectoryPath) { ProgramDataPath = programDataPath; - ProgramSystemPath = appFolderPath; LogDirectoryPath = logDirectoryPath; ConfigurationDirectoryPath = configurationDirectoryPath; CachePath = cacheDirectoryPath; + + DataPath = Path.Combine(ProgramDataPath, "data"); } + /// <summary> + /// Gets the path to the program data folder + /// </summary> + /// <value>The program data path.</value> public string ProgramDataPath { get; private set; } /// <summary> /// Gets the path to the system folder /// </summary> - public string ProgramSystemPath { get; private set; } + public string ProgramSystemPath { get; } = AppContext.BaseDirectory; /// <summary> - /// The _data directory - /// </summary> - private string _dataDirectory; - /// <summary> /// Gets the folder path to the data directory /// </summary> /// <value>The data directory.</value> + private string _dataPath; public string DataPath { - get - { - if (_dataDirectory == null) - { - _dataDirectory = Path.Combine(ProgramDataPath, "data"); - - Directory.CreateDirectory(_dataDirectory); - } - - return _dataDirectory; - } + get => _dataPath; + private set => _dataPath = Directory.CreateDirectory(value).FullName; } - private const string _virtualDataPath = "%AppDataPath%"; - public string VirtualDataPath => _virtualDataPath; + /// <summary> + /// Gets the magic strings used for virtual path manipulation. + /// </summary> + public string VirtualDataPath { get; } = "%AppDataPath%"; /// <summary> /// Gets the image cache path. @@ -84,54 +79,16 @@ namespace Emby.Server.Implementations.AppBase public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates"); /// <summary> - /// The _log directory - /// </summary> - private string _logDirectoryPath; - - /// <summary> /// Gets the path to the log directory /// </summary> /// <value>The log directory path.</value> - public string LogDirectoryPath - { - get - { - if (string.IsNullOrEmpty(_logDirectoryPath)) - { - _logDirectoryPath = Path.Combine(ProgramDataPath, "logs"); - - Directory.CreateDirectory(_logDirectoryPath); - } - - return _logDirectoryPath; - } - set => _logDirectoryPath = value; - } - - /// <summary> - /// The _config directory - /// </summary> - private string _configurationDirectoryPath; + public string LogDirectoryPath { get; private set; } /// <summary> /// Gets the path to the application configuration root directory /// </summary> /// <value>The configuration directory path.</value> - public string ConfigurationDirectoryPath - { - get - { - if (string.IsNullOrEmpty(_configurationDirectoryPath)) - { - _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config"); - - Directory.CreateDirectory(_configurationDirectoryPath); - } - - return _configurationDirectoryPath; - } - set => _configurationDirectoryPath = value; - } + public string ConfigurationDirectoryPath { get; private set; } /// <summary> /// Gets the path to the system configuration file @@ -140,28 +97,10 @@ namespace Emby.Server.Implementations.AppBase public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml"); /// <summary> - /// The _cache directory - /// </summary> - private string _cachePath; - /// <summary> /// Gets the folder path to the cache directory /// </summary> /// <value>The cache directory.</value> - public string CachePath - { - get - { - if (string.IsNullOrEmpty(_cachePath)) - { - _cachePath = Path.Combine(ProgramDataPath, "cache"); - - Directory.CreateDirectory(_cachePath); - } - - return _cachePath; - } - set => _cachePath = value; - } + public string CachePath { get; set; } /// <summary> /// Gets the folder path to the temp directory within the cache folder diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index d7fa4d4c2..af60a8dce 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -171,16 +171,29 @@ namespace Emby.Server.Implementations.AppBase private void UpdateCachePath() { string cachePath; - + // If the configuration file has no entry (i.e. not set in UI) if (string.IsNullOrWhiteSpace(CommonConfiguration.CachePath)) { - cachePath = null; + // If the current live configuration has no entry (i.e. not set on CLI/envvars, during startup) + if (string.IsNullOrWhiteSpace(((BaseApplicationPaths)CommonApplicationPaths).CachePath)) + { + // Set cachePath to a default value under ProgramDataPath + cachePath = Path.Combine(((BaseApplicationPaths)CommonApplicationPaths).ProgramDataPath, "cache"); + } + else + { + // Set cachePath to the existing live value; will require restart if UI value is removed (but not replaced) + // TODO: Figure out how to re-grab this from the CLI/envvars while running + cachePath = ((BaseApplicationPaths)CommonApplicationPaths).CachePath; + } } else { - cachePath = Path.Combine(CommonConfiguration.CachePath, "cache"); + // Set cachePath to the new UI-set value + cachePath = CommonConfiguration.CachePath; } + Logger.LogInformation("Setting cache path to " + cachePath); ((BaseApplicationPaths)CommonApplicationPaths).CachePath = cachePath; } |
