From 74d2698c5fd7f70b2409afc5be0e9825c5edeeda Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sat, 9 Feb 2019 18:37:35 -0500 Subject: [PATCH 1/2] Fix poor handling of cache directories --- .../AppBase/BaseConfigurationManager.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 460809e936..cf07cb1ecf 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 = (((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; } From 382b8bb509bbce34354a5d667c755b91d52c4fa4 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sat, 9 Feb 2019 19:14:34 -0500 Subject: [PATCH 2/2] Use Path.Combine --- Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index cf07cb1ecf..5feac1adf9 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -178,7 +178,7 @@ namespace Emby.Server.Implementations.AppBase if (string.IsNullOrWhiteSpace(((BaseApplicationPaths)CommonApplicationPaths).CachePath)) { // Set cachePath to a default value under ProgramDataPath - cachePath = (((BaseApplicationPaths)CommonApplicationPaths).ProgramDataPath + "/cache"); + cachePath = Path.Combine(((BaseApplicationPaths)CommonApplicationPaths).ProgramDataPath, "cache"); } else {