aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/AppBase
diff options
context:
space:
mode:
authorLogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>2019-01-23 00:31:35 -0800
committerGitHub <noreply@github.com>2019-01-23 00:31:35 -0800
commit404bd04cbc17dc8c8bf4a5c9aa3ca9c5cd85aa68 (patch)
tree3d267c6ceef9439a034c113095e10e4d619e7c70 /Emby.Server.Implementations/AppBase
parent8ff89fdc0c30f595a171ffc550f907ef22b6212a (diff)
parente05e002b8bb4d13eb2b80b56a0aad8903ddb701e (diff)
Merge pull request #8 from jellyfin/master
rebase to latest master
Diffstat (limited to 'Emby.Server.Implementations/AppBase')
-rw-r--r--Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs90
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs13
-rw-r--r--Emby.Server.Implementations/AppBase/ConfigurationHelper.cs3
3 files changed, 39 insertions, 67 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index 76d0076a6..e4a2cd9df 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -1,4 +1,4 @@
-using System.IO;
+using System.IO;
using MediaBrowser.Common.Configuration;
namespace Emby.Server.Implementations.AppBase
@@ -12,11 +12,16 @@ namespace Emby.Server.Implementations.AppBase
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
/// </summary>
- protected BaseApplicationPaths(string programDataPath, string appFolderPath, string logDirectoryPath)
+ protected BaseApplicationPaths(
+ string programDataPath,
+ string appFolderPath,
+ string logDirectoryPath = null,
+ string configurationDirectoryPath = null)
{
ProgramDataPath = programDataPath;
ProgramSystemPath = appFolderPath;
LogDirectoryPath = logDirectoryPath;
+ ConfigurationDirectoryPath = configurationDirectoryPath;
}
public string ProgramDataPath { get; private set; }
@@ -50,61 +55,31 @@ namespace Emby.Server.Implementations.AppBase
}
private const string _virtualDataPath = "%AppDataPath%";
- public string VirtualDataPath
- {
- get
- {
- return _virtualDataPath;
- }
- }
+ public string VirtualDataPath => _virtualDataPath;
/// <summary>
/// Gets the image cache path.
/// </summary>
/// <value>The image cache path.</value>
- public string ImageCachePath
- {
- get
- {
- return Path.Combine(CachePath, "images");
- }
- }
+ public string ImageCachePath => Path.Combine(CachePath, "images");
/// <summary>
/// Gets the path to the plugin directory
/// </summary>
/// <value>The plugins path.</value>
- public string PluginsPath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "plugins");
- }
- }
+ public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
/// <summary>
/// Gets the path to the plugin configurations directory
/// </summary>
/// <value>The plugin configurations path.</value>
- public string PluginConfigurationsPath
- {
- get
- {
- return Path.Combine(PluginsPath, "configurations");
- }
- }
+ public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
/// <summary>
/// Gets the path to where temporary update files will be stored
/// </summary>
/// <value>The plugin configurations path.</value>
- public string TempUpdatePath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "updates");
- }
- }
+ public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates");
/// <summary>
/// The _log directory
@@ -128,13 +103,15 @@ namespace Emby.Server.Implementations.AppBase
return _logDirectoryPath;
}
- set
- {
- _logDirectoryPath = value;
- }
+ set => _logDirectoryPath = value;
}
/// <summary>
+ /// The _config directory
+ /// </summary>
+ private string _configurationDirectoryPath;
+
+ /// <summary>
/// Gets the path to the application configuration root directory
/// </summary>
/// <value>The configuration directory path.</value>
@@ -142,21 +119,23 @@ namespace Emby.Server.Implementations.AppBase
{
get
{
- return Path.Combine(ProgramDataPath, "config");
+ if (string.IsNullOrEmpty(_configurationDirectoryPath))
+ {
+ _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
+
+ Directory.CreateDirectory(_configurationDirectoryPath);
+ }
+
+ return _configurationDirectoryPath;
}
+ set => _configurationDirectoryPath = value;
}
/// <summary>
/// Gets the path to the system configuration file
/// </summary>
/// <value>The system configuration file path.</value>
- public string SystemConfigurationFilePath
- {
- get
- {
- return Path.Combine(ConfigurationDirectoryPath, "system.xml");
- }
- }
+ public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
/// <summary>
/// The _cache directory
@@ -179,22 +158,13 @@ namespace Emby.Server.Implementations.AppBase
return _cachePath;
}
- set
- {
- _cachePath = value;
- }
+ set => _cachePath = value;
}
/// <summary>
/// Gets the folder path to the temp directory within the cache folder
/// </summary>
/// <value>The temp directory.</value>
- public string TempDirectory
- {
- get
- {
- return Path.Combine(CachePath, "temp");
- }
- }
+ public string TempDirectory => Path.Combine(CachePath, "temp");
}
}
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index bc5168fe8..59c7c655f 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
@@ -9,8 +9,8 @@ using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.AppBase
{
@@ -99,6 +99,7 @@ namespace Emby.Server.Implementations.AppBase
/// <param name="applicationPaths">The application paths.</param>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
+ /// <param name="fileSystem">The file system</param>
protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
{
CommonApplicationPaths = applicationPaths;
@@ -150,12 +151,12 @@ namespace Emby.Server.Implementations.AppBase
/// Replaces the configuration.
/// </summary>
/// <param name="newConfiguration">The new configuration.</param>
- /// <exception cref="System.ArgumentNullException">newConfiguration</exception>
+ /// <exception cref="ArgumentNullException">newConfiguration</exception>
public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration)
{
if (newConfiguration == null)
{
- throw new ArgumentNullException("newConfiguration");
+ throw new ArgumentNullException(nameof(newConfiguration));
}
ValidateCachePath(newConfiguration);
@@ -187,7 +188,7 @@ namespace Emby.Server.Implementations.AppBase
/// Replaces the cache path.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
- /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
+ /// <exception cref="DirectoryNotFoundException"></exception>
private void ValidateCachePath(BaseApplicationConfiguration newConfig)
{
var newPath = newConfig.CachePath;
@@ -283,7 +284,7 @@ namespace Emby.Server.Implementations.AppBase
validatingStore.Validate(currentConfiguration, configuration);
}
- NamedConfigurationUpdating?.Invoke( this, new ConfigurationUpdateEventArgs
+ NamedConfigurationUpdating?.Invoke(this, new ConfigurationUpdateEventArgs
{
Key = key,
NewConfiguration = configuration
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
index d6a41dd67..ee6da95fe 100644
--- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
+++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Linq;
using MediaBrowser.Model.IO;
@@ -18,6 +18,7 @@ namespace Emby.Server.Implementations.AppBase
/// <param name="type">The type.</param>
/// <param name="path">The path.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
+ /// <param name="fileSystem">The file system</param>
/// <returns>System.Object.</returns>
public static object GetXmlConfiguration(Type type, string path, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
{