aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-11 00:45:34 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-11 00:45:34 -0500
commit369d5e8f09e4e6e7e493bf2049325251942cd215 (patch)
tree75b9e2f927119febea297e947ee8acd46acb2f45 /MediaBrowser.Server.Startup.Common
parent68b3ca63837e572756e6670547ea2e27d995cbe3 (diff)
update core project
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
-rw-r--r--MediaBrowser.Server.Startup.Common/Configuration/ServerConfigurationManager.cs257
-rw-r--r--MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj2
-rw-r--r--MediaBrowser.Server.Startup.Common/ServerApplicationPaths.cs233
3 files changed, 0 insertions, 492 deletions
diff --git a/MediaBrowser.Server.Startup.Common/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Startup.Common/Configuration/ServerConfigurationManager.cs
deleted file mode 100644
index 756a8d0bf9..0000000000
--- a/MediaBrowser.Server.Startup.Common/Configuration/ServerConfigurationManager.cs
+++ /dev/null
@@ -1,257 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Emby.Common.Implementations.Configuration;
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.Events;
-using MediaBrowser.Controller;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
-using MediaBrowser.Controller.Entities.Movies;
-using MediaBrowser.Controller.Entities.TV;
-using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.Events;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Serialization;
-
-namespace MediaBrowser.Server.Startup.Common.Configuration
-{
- /// <summary>
- /// Class ServerConfigurationManager
- /// </summary>
- public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager
- {
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ServerConfigurationManager" /> class.
- /// </summary>
- /// <param name="applicationPaths">The application paths.</param>
- /// <param name="logManager">The log manager.</param>
- /// <param name="xmlSerializer">The XML serializer.</param>
- /// <param name="fileSystem">The file system.</param>
- public ServerConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
- : base(applicationPaths, logManager, xmlSerializer, fileSystem)
- {
- UpdateMetadataPath();
- }
-
- public event EventHandler<GenericEventArgs<ServerConfiguration>> ConfigurationUpdating;
-
- /// <summary>
- /// Gets the type of the configuration.
- /// </summary>
- /// <value>The type of the configuration.</value>
- protected override Type ConfigurationType
- {
- get { return typeof(ServerConfiguration); }
- }
-
- /// <summary>
- /// Gets the application paths.
- /// </summary>
- /// <value>The application paths.</value>
- public IServerApplicationPaths ApplicationPaths
- {
- get { return (IServerApplicationPaths)CommonApplicationPaths; }
- }
-
- /// <summary>
- /// Gets the configuration.
- /// </summary>
- /// <value>The configuration.</value>
- public ServerConfiguration Configuration
- {
- get { return (ServerConfiguration)CommonConfiguration; }
- }
-
- /// <summary>
- /// Called when [configuration updated].
- /// </summary>
- protected override void OnConfigurationUpdated()
- {
- UpdateMetadataPath();
-
- base.OnConfigurationUpdated();
- }
-
- public override void AddParts(IEnumerable<IConfigurationFactory> factories)
- {
- base.AddParts(factories);
-
- UpdateTranscodingTempPath();
- }
-
- /// <summary>
- /// Updates the metadata path.
- /// </summary>
- private void UpdateMetadataPath()
- {
- string metadataPath;
-
- if (string.IsNullOrWhiteSpace(Configuration.MetadataPath))
- {
- metadataPath = GetInternalMetadataPath();
- }
- else
- {
- metadataPath = Path.Combine(Configuration.MetadataPath, "metadata");
- }
-
- ((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = metadataPath;
-
- ((ServerApplicationPaths)ApplicationPaths).ItemsByNamePath = ((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath;
- }
-
- private string GetInternalMetadataPath()
- {
- return Path.Combine(ApplicationPaths.ProgramDataPath, "metadata");
- }
-
- /// <summary>
- /// Updates the transcoding temporary path.
- /// </summary>
- private void UpdateTranscodingTempPath()
- {
- var encodingConfig = this.GetConfiguration<EncodingOptions>("encoding");
-
- ((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ?
- null :
- Path.Combine(encodingConfig.TranscodingTempPath, "transcoding-temp");
- }
-
- protected override void OnNamedConfigurationUpdated(string key, object configuration)
- {
- base.OnNamedConfigurationUpdated(key, configuration);
-
- if (string.Equals(key, "encoding", StringComparison.OrdinalIgnoreCase))
- {
- UpdateTranscodingTempPath();
- }
- }
-
- /// <summary>
- /// Replaces the configuration.
- /// </summary>
- /// <param name="newConfiguration">The new configuration.</param>
- /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
- public override void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration)
- {
- var newConfig = (ServerConfiguration)newConfiguration;
-
- ValidatePathSubstitutions(newConfig);
- ValidateMetadataPath(newConfig);
- ValidateSslCertificate(newConfig);
-
- EventHelper.FireEventIfNotNull(ConfigurationUpdating, this, new GenericEventArgs<ServerConfiguration> { Argument = newConfig }, Logger);
-
- base.ReplaceConfiguration(newConfiguration);
- }
-
-
- /// <summary>
- /// Validates the SSL certificate.
- /// </summary>
- /// <param name="newConfig">The new configuration.</param>
- /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
- private void ValidateSslCertificate(BaseApplicationConfiguration newConfig)
- {
- var serverConfig = (ServerConfiguration)newConfig;
-
- var newPath = serverConfig.CertificatePath;
-
- if (!string.IsNullOrWhiteSpace(newPath)
- && !string.Equals(Configuration.CertificatePath ?? string.Empty, newPath))
- {
- // Validate
- if (!FileSystem.FileExists(newPath))
- {
- throw new FileNotFoundException(string.Format("Certificate file '{0}' does not exist.", newPath));
- }
- }
- }
-
- private void ValidatePathSubstitutions(ServerConfiguration newConfig)
- {
- foreach (var map in newConfig.PathSubstitutions)
- {
- if (string.IsNullOrWhiteSpace(map.From) || string.IsNullOrWhiteSpace(map.To))
- {
- throw new ArgumentException("Invalid path substitution");
- }
- }
- }
-
- /// <summary>
- /// Validates the metadata path.
- /// </summary>
- /// <param name="newConfig">The new configuration.</param>
- /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
- private void ValidateMetadataPath(ServerConfiguration newConfig)
- {
- var newPath = newConfig.MetadataPath;
-
- if (!string.IsNullOrWhiteSpace(newPath)
- && !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath))
- {
- // Validate
- if (!FileSystem.DirectoryExists(newPath))
- {
- throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath));
- }
-
- EnsureWriteAccess(newPath);
- }
- }
-
- public void DisableMetadataService(string service)
- {
- DisableMetadataService(typeof(Movie), Configuration, service);
- DisableMetadataService(typeof(Episode), Configuration, service);
- DisableMetadataService(typeof(Series), Configuration, service);
- DisableMetadataService(typeof(Season), Configuration, service);
- DisableMetadataService(typeof(MusicArtist), Configuration, service);
- DisableMetadataService(typeof(MusicAlbum), Configuration, service);
- DisableMetadataService(typeof(MusicVideo), Configuration, service);
- DisableMetadataService(typeof(Video), Configuration, service);
- }
-
- private void DisableMetadataService(Type type, ServerConfiguration config, string service)
- {
- var options = GetMetadataOptions(type, config);
-
- if (!options.DisabledMetadataSavers.Contains(service, StringComparer.OrdinalIgnoreCase))
- {
- var list = options.DisabledMetadataSavers.ToList();
-
- list.Add(service);
-
- options.DisabledMetadataSavers = list.ToArray();
- }
- }
-
- private MetadataOptions GetMetadataOptions(Type type, ServerConfiguration config)
- {
- var options = config.MetadataOptions
- .FirstOrDefault(i => string.Equals(i.ItemType, type.Name, StringComparison.OrdinalIgnoreCase));
-
- if (options == null)
- {
- var list = config.MetadataOptions.ToList();
-
- options = new MetadataOptions
- {
- ItemType = type.Name
- };
-
- list.Add(options);
-
- config.MetadataOptions = list.ToArray();
- }
-
- return options;
- }
- }
-}
diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
index 7d6df52c20..6196a74a2b 100644
--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
@@ -96,7 +96,6 @@
<Compile Include="Activity\ActivityRepository.cs" />
<Compile Include="ApplicationHost.cs" />
<Compile Include="ApplicationPathHelper.cs" />
- <Compile Include="Configuration\ServerConfigurationManager.cs" />
<Compile Include="Devices\DeviceRepository.cs" />
<Compile Include="EntryPoints\ExternalPortForwarding.cs" />
<Compile Include="FFMpeg\FFMpegLoader.cs" />
@@ -165,7 +164,6 @@
<Compile Include="Cryptography\X509Extension.cs" />
<Compile Include="Cryptography\X509Extensions.cs" />
<Compile Include="Cryptography\X520Attributes.cs" />
- <Compile Include="ServerApplicationPaths.cs" />
<Compile Include="Social\SharingRepository.cs" />
<Compile Include="Sync\SyncRepository.cs" />
<Compile Include="SystemEvents.cs" />
diff --git a/MediaBrowser.Server.Startup.Common/ServerApplicationPaths.cs b/MediaBrowser.Server.Startup.Common/ServerApplicationPaths.cs
deleted file mode 100644
index 11de1c4abc..0000000000
--- a/MediaBrowser.Server.Startup.Common/ServerApplicationPaths.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-using System.IO;
-using Emby.Common.Implementations;
-using MediaBrowser.Controller;
-
-namespace MediaBrowser.Server.Startup.Common
-{
- /// <summary>
- /// Extends BaseApplicationPaths to add paths that are only applicable on the server
- /// </summary>
- public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
- /// </summary>
- public ServerApplicationPaths(string programDataPath, string applicationPath, string applicationResourcesPath)
- : base(programDataPath, applicationPath)
- {
- ApplicationResourcesPath = applicationResourcesPath;
- }
-
- public string ApplicationResourcesPath { get; private set; }
-
- /// <summary>
- /// Gets the path to the base root media directory
- /// </summary>
- /// <value>The root folder path.</value>
- public string RootFolderPath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "root");
- }
- }
-
- /// <summary>
- /// Gets the path to the default user view directory. Used if no specific user view is defined.
- /// </summary>
- /// <value>The default user views path.</value>
- public string DefaultUserViewsPath
- {
- get
- {
- return Path.Combine(RootFolderPath, "default");
- }
- }
-
- /// <summary>
- /// Gets the path to localization data.
- /// </summary>
- /// <value>The localization path.</value>
- public string LocalizationPath
- {
- get
- {
- return Path.Combine(ProgramDataPath, "localization");
- }
- }
-
- /// <summary>
- /// The _ibn path
- /// </summary>
- private string _ibnPath;
- /// <summary>
- /// Gets the path to the Images By Name directory
- /// </summary>
- /// <value>The images by name path.</value>
- public string ItemsByNamePath
- {
- get
- {
- return _ibnPath ?? (_ibnPath = Path.Combine(ProgramDataPath, "ImagesByName"));
- }
- set
- {
- _ibnPath = value;
- }
- }
-
- /// <summary>
- /// Gets the path to the People directory
- /// </summary>
- /// <value>The people path.</value>
- public string PeoplePath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "People");
- }
- }
-
- public string ArtistsPath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "artists");
- }
- }
-
- /// <summary>
- /// Gets the path to the Genre directory
- /// </summary>
- /// <value>The genre path.</value>
- public string GenrePath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "Genre");
- }
- }
-
- /// <summary>
- /// Gets the path to the Genre directory
- /// </summary>
- /// <value>The genre path.</value>
- public string MusicGenrePath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "MusicGenre");
- }
- }
-
- /// <summary>
- /// Gets the path to the Studio directory
- /// </summary>
- /// <value>The studio path.</value>
- public string StudioPath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "Studio");
- }
- }
-
- /// <summary>
- /// Gets the path to the Year directory
- /// </summary>
- /// <value>The year path.</value>
- public string YearPath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "Year");
- }
- }
-
- /// <summary>
- /// Gets the path to the General IBN directory
- /// </summary>
- /// <value>The general path.</value>
- public string GeneralPath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "general");
- }
- }
-
- /// <summary>
- /// Gets the path to the Ratings IBN directory
- /// </summary>
- /// <value>The ratings path.</value>
- public string RatingsPath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "ratings");
- }
- }
-
- /// <summary>
- /// Gets the media info images path.
- /// </summary>
- /// <value>The media info images path.</value>
- public string MediaInfoImagesPath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "mediainfo");
- }
- }
-
- /// <summary>
- /// Gets the path to the user configuration directory
- /// </summary>
- /// <value>The user configuration directory path.</value>
- public string UserConfigurationDirectoryPath
- {
- get
- {
- return Path.Combine(ConfigurationDirectoryPath, "users");
- }
- }
-
- private string _transcodingTempPath;
- public string TranscodingTempPath
- {
- get
- {
- return _transcodingTempPath ?? (_transcodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp"));
- }
- set
- {
- _transcodingTempPath = value;
- }
- }
-
- /// <summary>
- /// Gets the game genre path.
- /// </summary>
- /// <value>The game genre path.</value>
- public string GameGenrePath
- {
- get
- {
- return Path.Combine(ItemsByNamePath, "GameGenre");
- }
- }
-
- private string _internalMetadataPath;
- public string InternalMetadataPath
- {
- get
- {
- return _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
- }
- set
- {
- _internalMetadataPath = value;
- }
- }
- }
-}