From 97ae93fe5eb0f010db9835efd72954f31ccdd2cd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 21 Dec 2014 14:40:37 -0500 Subject: add standalone EncodingOptions --- .../Configuration/ServerConfigurationManager.cs | 33 ---------------------- 1 file changed, 33 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Configuration') diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index b9896e9ce..704bdea29 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -32,7 +32,6 @@ namespace MediaBrowser.Server.Implementations.Configuration : base(applicationPaths, logManager, xmlSerializer) { UpdateItemsByNamePath(); - UpdateTranscodingTempPath(); UpdateMetadataPath(); } @@ -71,7 +70,6 @@ namespace MediaBrowser.Server.Implementations.Configuration protected override void OnConfigurationUpdated() { UpdateItemsByNamePath(); - UpdateTranscodingTempPath(); UpdateMetadataPath(); base.OnConfigurationUpdated(); @@ -97,16 +95,6 @@ namespace MediaBrowser.Server.Implementations.Configuration Configuration.MetadataPath; } - /// - /// Updates the transcoding temporary path. - /// - private void UpdateTranscodingTempPath() - { - ((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(Configuration.TranscodingTempPath) ? - null : - Configuration.TranscodingTempPath; - } - /// /// Replaces the configuration. /// @@ -117,7 +105,6 @@ namespace MediaBrowser.Server.Implementations.Configuration var newConfig = (ServerConfiguration)newConfiguration; ValidateItemByNamePath(newConfig); - ValidateTranscodingTempPath(newConfig); ValidatePathSubstitutions(newConfig); ValidateMetadataPath(newConfig); @@ -157,26 +144,6 @@ namespace MediaBrowser.Server.Implementations.Configuration } } - /// - /// Validates the transcoding temporary path. - /// - /// The new configuration. - /// - private void ValidateTranscodingTempPath(ServerConfiguration newConfig) - { - var newPath = newConfig.TranscodingTempPath; - - if (!string.IsNullOrWhiteSpace(newPath) - && !string.Equals(Configuration.TranscodingTempPath ?? string.Empty, newPath)) - { - // Validate - if (!Directory.Exists(newPath)) - { - throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); - } - } - } - /// /// Validates the metadata path. /// -- cgit v1.2.3 From 98ae564226115eeb41cc01b54bb6c9a1707ece3b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 21 Dec 2014 20:02:15 -0500 Subject: add transcode temp path migration --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- .../Configuration/BaseConfigurationManager.cs | 7 +++- .../Configuration/ServerConfigurationManager.cs | 32 +++++++++++++++++- .../ApplicationHost.cs | 39 +++++++++++++++------- .../MediaBrowser.Server.Startup.Common.csproj | 1 + .../Migrations/MigrateTranscodingPath.cs | 30 +++++++++++++++++ 6 files changed, 96 insertions(+), 15 deletions(-) create mode 100644 MediaBrowser.Server.Startup.Common/Migrations/MigrateTranscodingPath.cs (limited to 'MediaBrowser.Server.Implementations/Configuration') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 683a1f962..7b18fb379 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -250,7 +250,7 @@ namespace MediaBrowser.Api.Playback protected EncodingQuality GetQualitySetting() { - var quality = ApiEntryPoint.Instance.GetEncodingOptions().MediaEncodingQuality; + var quality = ApiEntryPoint.Instance.GetEncodingOptions().EncodingQuality; if (quality == EncodingQuality.Auto) { diff --git a/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs b/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs index 093010124..89f6229ac 100644 --- a/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs +++ b/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs @@ -105,7 +105,7 @@ namespace MediaBrowser.Common.Implementations.Configuration UpdateCachePath(); } - public void AddParts(IEnumerable factories) + public virtual void AddParts(IEnumerable factories) { _configurationFactories = factories.ToArray(); @@ -266,6 +266,11 @@ namespace MediaBrowser.Common.Implementations.Configuration XmlSerializer.SerializeToFile(configuration, path); } + OnNamedConfigurationUpdated(key, configuration); + } + + protected virtual void OnNamedConfigurationUpdated(string key, object configuration) + { EventHelper.FireEventIfNotNull(NamedConfigurationUpdated, this, new ConfigurationUpdateEventArgs { Key = key, diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index 704bdea29..b3b8ccbd8 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.Collections.Generic; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; using MediaBrowser.Common.Implementations.Configuration; using MediaBrowser.Controller; @@ -75,6 +76,13 @@ namespace MediaBrowser.Server.Implementations.Configuration base.OnConfigurationUpdated(); } + public override void AddParts(IEnumerable factories) + { + base.AddParts(factories); + + UpdateTranscodingTempPath(); + } + /// /// Updates the items by name path. /// @@ -95,6 +103,28 @@ namespace MediaBrowser.Server.Implementations.Configuration Configuration.MetadataPath; } + /// + /// Updates the transcoding temporary path. + /// + private void UpdateTranscodingTempPath() + { + var encodingConfig = this.GetConfiguration("encoding"); + + ((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ? + null : + encodingConfig.TranscodingTempPath; + } + + protected override void OnNamedConfigurationUpdated(string key, object configuration) + { + base.OnNamedConfigurationUpdated(key, configuration); + + if (string.Equals(key, "encoding", StringComparison.OrdinalIgnoreCase)) + { + UpdateTranscodingTempPath(); + } + } + /// /// Replaces the configuration. /// diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 2af33c311..c2520ff6b 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -238,12 +238,12 @@ namespace MediaBrowser.Server.Startup.Common /// Name of the remote package. /// if set to true [supports native web socket]. /// The native application. - public ApplicationHost(ServerApplicationPaths applicationPaths, - ILogManager logManager, - StartupOptions options, + public ApplicationHost(ServerApplicationPaths applicationPaths, + ILogManager logManager, + StartupOptions options, IFileSystem fileSystem, - string remotePackageName, - bool supportsNativeWebSocket, + string remotePackageName, + bool supportsNativeWebSocket, INativeApp nativeApp) : base(applicationPaths, logManager, fileSystem) { @@ -353,12 +353,14 @@ namespace MediaBrowser.Server.Startup.Common public override async Task Init(IProgress progress) { - PerformVersionMigration(); + PerformPreInitMigrations(); await base.Init(progress).ConfigureAwait(false); + + PerformPostInitMigrations(); } - private void PerformVersionMigration() + private void PerformPreInitMigrations() { var migrations = new List { @@ -375,6 +377,19 @@ namespace MediaBrowser.Server.Startup.Common } } + private void PerformPostInitMigrations() + { + var migrations = new List + { + new MigrateTranscodingPath(ServerConfigurationManager) + }; + + foreach (var task in migrations) + { + task.Run(); + } + } + /// /// Registers resources that classes will depend on /// @@ -383,7 +398,7 @@ namespace MediaBrowser.Server.Startup.Common { await base.RegisterResources(progress).ConfigureAwait(false); - RegisterSingleInstance(new HttpResultFactory(LogManager, FileSystemManager, JsonSerializer)); + RegisterSingleInstance(new HttpResultFactory(LogManager, FileSystemManager, JsonSerializer)); RegisterSingleInstance(this); RegisterSingleInstance(ApplicationPaths); @@ -398,7 +413,7 @@ namespace MediaBrowser.Server.Startup.Common UserDataManager = new UserDataManager(LogManager); RegisterSingleInstance(UserDataManager); - UserRepository = await GetUserRepository().ConfigureAwait(false); + UserRepository = await GetUserRepository().ConfigureAwait(false); RegisterSingleInstance(UserRepository); DisplayPreferencesRepository = new SqliteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager); @@ -439,7 +454,7 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance(() => new SearchEngine(LogManager, LibraryManager, UserManager)); - HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", _supportsNativeWebSocket); + HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", _supportsNativeWebSocket); RegisterSingleInstance(HttpServer, false); progress.Report(10); @@ -533,12 +548,12 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance(new SessionContext(UserManager, authContext, SessionManager)); RegisterSingleInstance(new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager, SessionManager)); - RegisterSingleInstance(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer)); + RegisterSingleInstance(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer)); await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false); await ConfigureItemRepositories().ConfigureAwait(false); await ConfigureUserDataRepositories().ConfigureAwait(false); - await ConfigureNotificationsRepository().ConfigureAwait(false); + await ConfigureNotificationsRepository().ConfigureAwait(false); progress.Report(100); SetStaticProperties(); diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj index ab53103e8..38e07fde4 100644 --- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj +++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj @@ -66,6 +66,7 @@ + diff --git a/MediaBrowser.Server.Startup.Common/Migrations/MigrateTranscodingPath.cs b/MediaBrowser.Server.Startup.Common/Migrations/MigrateTranscodingPath.cs new file mode 100644 index 000000000..88f60841d --- /dev/null +++ b/MediaBrowser.Server.Startup.Common/Migrations/MigrateTranscodingPath.cs @@ -0,0 +1,30 @@ +using MediaBrowser.Common.Configuration; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; + +namespace MediaBrowser.Server.Startup.Common.Migrations +{ + public class MigrateTranscodingPath : IVersionMigration + { + private readonly IServerConfigurationManager _config; + + public MigrateTranscodingPath(IServerConfigurationManager config) + { + _config = config; + } + + public void Run() + { + if (!string.IsNullOrWhiteSpace(_config.Configuration.TranscodingTempPath)) + { + var newConfig = _config.GetConfiguration("encoding"); + + newConfig.TranscodingTempPath = _config.Configuration.TranscodingTempPath; + _config.SaveConfiguration("encoding", newConfig); + + _config.Configuration.TranscodingTempPath = null; + _config.SaveConfiguration(); + } + } + } +} -- cgit v1.2.3