From 340280edf29cfbf6b519b7fb6312f90e2c1f9871 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Wed, 27 Feb 2013 07:49:55 -0500 Subject: [PATCH 1/3] Partial implementation of PackageManager --- ...MediaBrowser.Common.Implementations.csproj | 5 +- .../Updates/PackageManager.cs | 47 +++++++ MediaBrowser.Common/Constants/Constants.cs | 13 ++ .../MediaBrowser.Common.csproj | 3 +- .../Updates/IInstallationManager.cs | 119 ------------------ .../Updates/IPackageManager.cs | 42 +++++++ MediaBrowser.Controller/Kernel.cs | 7 +- .../Updates/InstallationManager.cs | 54 ++++---- .../ApplicationHost.cs | 13 +- 9 files changed, 141 insertions(+), 162 deletions(-) create mode 100644 MediaBrowser.Common.Implementations/Updates/PackageManager.cs create mode 100644 MediaBrowser.Common/Constants/Constants.cs delete mode 100644 MediaBrowser.Common/Updates/IInstallationManager.cs create mode 100644 MediaBrowser.Common/Updates/IPackageManager.cs diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index 70d92edb5..a8dfe33cf 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -129,6 +129,7 @@ + @@ -163,9 +164,7 @@ - - - + diff --git a/MediaBrowser.Common.Implementations/Updates/PackageManager.cs b/MediaBrowser.Common.Implementations/Updates/PackageManager.cs new file mode 100644 index 000000000..3f09615e7 --- /dev/null +++ b/MediaBrowser.Common.Implementations/Updates/PackageManager.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.Net; +using MediaBrowser.Common.Security; +using MediaBrowser.Common.Updates; +using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Updates; + +namespace MediaBrowser.Common.Implementations.Updates +{ + public class PackageManager : IPackageManager + { + public async Task> GetAvailablePackages(IHttpClient client, + INetworkManager networkManager, + ISecurityManager securityManager, + ResourcePool resourcePool, + IJsonSerializer serializer, + CancellationToken cancellationToken) + { + var data = new Dictionary { { "key", securityManager.SupporterKey }, { "mac", networkManager.GetMacAddress() } }; + + using (var json = await client.Post(Constants.Constants.MBAdminUrl + "service/package/retrieveall", data, resourcePool.Mb, cancellationToken).ConfigureAwait(false)) + { + cancellationToken.ThrowIfCancellationRequested(); + + var packages = serializer.DeserializeFromStream>(json).ToList(); + foreach (var package in packages) + { + package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) + .OrderByDescending(v => v.version).ToList(); + } + + return packages; + } + + } + + public Task InstallPackage(PackageVersionInfo package, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + } +} diff --git a/MediaBrowser.Common/Constants/Constants.cs b/MediaBrowser.Common/Constants/Constants.cs new file mode 100644 index 000000000..e8a347829 --- /dev/null +++ b/MediaBrowser.Common/Constants/Constants.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MediaBrowser.Common.Constants +{ + public static class Constants + { + public const string MBAdminUrl = "http://mb3admin.com/admin/"; + } +} diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index 50ca0e5bc..1b63f936f 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -47,6 +47,7 @@ Properties\SharedVersion.cs + @@ -104,7 +105,7 @@ - + diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs deleted file mode 100644 index 23c147748..000000000 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Plugins; -using MediaBrowser.Model.Updates; - -namespace MediaBrowser.Common.Updates -{ - public interface IInstallationManager - { - /// - /// The current installations - /// - List> CurrentInstallations { get; set; } - - /// - /// The completed installations - /// - ConcurrentBag CompletedInstallations { get; set; } - - /// - /// Occurs when [plugin uninstalled]. - /// - event EventHandler> PluginUninstalled; - - /// - /// Occurs when [plugin updated]. - /// - event EventHandler>> PluginUpdated; - - /// - /// Called when [plugin updated]. - /// - /// The plugin. - /// The new version. - void OnPluginUpdated(IPlugin plugin, PackageVersionInfo newVersion); - - /// - /// Occurs when [plugin updated]. - /// - event EventHandler> PluginInstalled; - - /// - /// Called when [plugin installed]. - /// - /// The package. - void OnPluginInstalled(PackageVersionInfo package); - - /// - /// Gets all available packages. - /// - /// The cancellation token. - /// Type of the package. - /// The application version. - /// Task{List{PackageInfo}}. - Task> GetAvailablePackages(CancellationToken cancellationToken, - PackageType? packageType = null, - Version applicationVersion = null); - - /// - /// Gets the package. - /// - /// The name. - /// The classification. - /// The version. - /// Task{PackageVersionInfo}. - Task GetPackage(string name, PackageVersionClass classification, Version version); - - /// - /// Gets the latest compatible version. - /// - /// The name. - /// The classification. - /// Task{PackageVersionInfo}. - Task GetLatestCompatibleVersion(string name, PackageVersionClass classification = PackageVersionClass.Release); - - /// - /// Gets the latest compatible version. - /// - /// The available packages. - /// The name. - /// The classification. - /// PackageVersionInfo. - PackageVersionInfo GetLatestCompatibleVersion(IEnumerable availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release); - - /// - /// Gets the available plugin updates. - /// - /// if set to true [with auto update enabled]. - /// The cancellation token. - /// Task{IEnumerable{PackageVersionInfo}}. - Task> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken); - - /// - /// Installs the package. - /// - /// The package. - /// The progress. - /// The cancellation token. - /// Task. - /// package - Task InstallPackage(PackageVersionInfo package, IProgress progress, CancellationToken cancellationToken); - - /// - /// Uninstalls a plugin - /// - /// The plugin. - /// - void UninstallPlugin(IPlugin plugin); - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - void Dispose(); - } -} \ No newline at end of file diff --git a/MediaBrowser.Common/Updates/IPackageManager.cs b/MediaBrowser.Common/Updates/IPackageManager.cs new file mode 100644 index 000000000..d5a8a59b1 --- /dev/null +++ b/MediaBrowser.Common/Updates/IPackageManager.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.Net; +using MediaBrowser.Common.Security; +using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Updates; + +namespace MediaBrowser.Common.Updates +{ + public interface IPackageManager + { + /// + /// Gets all available packages. + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// Task{List{PackageInfo}}. + Task> GetAvailablePackages(IHttpClient client, + INetworkManager networkManager, + ISecurityManager securityManager, + ResourcePool resourcePool, + IJsonSerializer serializer, + CancellationToken cancellationToken); + + /// + /// Installs a package. + /// + /// The package. + /// The cancellation token. + /// Task. + Task InstallPackage(PackageVersionInfo package, CancellationToken cancellationToken); + } +} diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index 6faa20012..6703012be 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -33,11 +33,6 @@ namespace MediaBrowser.Controller /// public class Kernel : BaseKernel { - /// - /// The MB admin URL - /// - public const string MBAdminUrl = "http://mb3admin.com/admin/"; - /// /// Gets the instance. /// @@ -72,7 +67,7 @@ namespace MediaBrowser.Controller /// Gets the installation manager. /// /// The installation manager. - public IInstallationManager InstallationManager { get; private set; } + public InstallationManager InstallationManager { get; private set; } /// /// Gets or sets the file system manager. diff --git a/MediaBrowser.Controller/Updates/InstallationManager.cs b/MediaBrowser.Controller/Updates/InstallationManager.cs index 633cc6bc3..ebd644a82 100644 --- a/MediaBrowser.Controller/Updates/InstallationManager.cs +++ b/MediaBrowser.Controller/Updates/InstallationManager.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Updates /// /// Manages all install, uninstall and update operations (both plugins and system) /// - public class InstallationManager : BaseManager, IInstallationManager + public class InstallationManager : BaseManager { /// /// The current installations @@ -109,6 +109,11 @@ namespace MediaBrowser.Controller.Updates /// private readonly INetworkManager _networkManager; + /// + /// The package manager + /// + private readonly IPackageManager _packageManager; + /// /// Gets the json serializer. /// @@ -134,11 +139,12 @@ namespace MediaBrowser.Controller.Updates /// The HTTP client. /// The zip client. /// The network manager. + /// The package manager. /// The json serializer. /// The logger. /// The app host. /// zipClient - public InstallationManager(Kernel kernel, IHttpClient httpClient, IZipClient zipClient, INetworkManager networkManager, IJsonSerializer jsonSerializer, ILogger logger, IApplicationHost appHost) + public InstallationManager(Kernel kernel, IHttpClient httpClient, IZipClient zipClient, INetworkManager networkManager, IPackageManager packageManager, IJsonSerializer jsonSerializer, ILogger logger, IApplicationHost appHost) : base(kernel) { if (zipClient == null) @@ -149,6 +155,10 @@ namespace MediaBrowser.Controller.Updates { throw new ArgumentNullException("networkManager"); } + if (packageManager == null) + { + throw new ArgumentNullException("packageManager"); + } if (logger == null) { throw new ArgumentNullException("logger"); @@ -168,6 +178,7 @@ namespace MediaBrowser.Controller.Updates HttpClient = httpClient; ApplicationHost = appHost; _networkManager = networkManager; + _packageManager = packageManager; _logger = logger; ZipClient = zipClient; } @@ -183,39 +194,26 @@ namespace MediaBrowser.Controller.Updates PackageType? packageType = null, Version applicationVersion = null) { - var data = new Dictionary { { "key", Kernel.SecurityManager.SupporterKey }, { "mac", _networkManager.GetMacAddress() } }; + var packages = (await _packageManager.GetAvailablePackages(HttpClient, _networkManager, Kernel.SecurityManager, Kernel.ResourcePools, JsonSerializer, cancellationToken).ConfigureAwait(false)).ToList(); - using (var json = await HttpClient.Post(Controller.Kernel.MBAdminUrl + "service/package/retrieveall", data, Kernel.ResourcePools.Mb, cancellationToken).ConfigureAwait(false)) + if (packageType.HasValue) { - cancellationToken.ThrowIfCancellationRequested(); - - var packages = JsonSerializer.DeserializeFromStream>(json).ToList(); + packages = packages.Where(p => p.type == packageType.Value).ToList(); + } + // If an app version was supplied, filter the versions for each package to only include supported versions + if (applicationVersion != null) + { foreach (var package in packages) { - package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(v => v.version).ToList(); + package.versions = package.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToList(); } - - if (packageType.HasValue) - { - packages = packages.Where(p => p.type == packageType.Value).ToList(); - } - - // If an app version was supplied, filter the versions for each package to only include supported versions - if (applicationVersion != null) - { - foreach (var package in packages) - { - package.versions = package.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToList(); - } - } - - // Remove packages with no versions - packages = packages.Where(p => p.versions.Any()).ToList(); - - return packages; } + + // Remove packages with no versions + packages = packages.Where(p => p.versions.Any()).ToList(); + + return packages; } /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index a252d92a6..2aa24dabf 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -7,13 +7,15 @@ using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Common.Implementations.NetworkManagement; using MediaBrowser.Common.Implementations.ScheduledTasks; using MediaBrowser.Common.Implementations.Serialization; +using MediaBrowser.Common.IO; using MediaBrowser.Common.Implementations.ServerManager; using MediaBrowser.Common.Implementations.Udp; +using MediaBrowser.Common.Implementations.Updates; using MediaBrowser.Common.Implementations.WebSocket; -using MediaBrowser.Common.IO; using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Net; using MediaBrowser.Common.ScheduledTasks; +using MediaBrowser.Common.Updates; using MediaBrowser.Controller; using MediaBrowser.IsoMounter; using MediaBrowser.Model.IO; @@ -72,7 +74,6 @@ namespace MediaBrowser.ServerApplication public ApplicationHost() : base() { - Logger.Info("ApplicationHost!!!!!!!!!!!!!!!!!!!!"); Kernel = new Kernel(this, ServerApplicationPaths, _xmlSerializer, Logger); var networkManager = new NetworkManager(); @@ -81,13 +82,15 @@ namespace MediaBrowser.ServerApplication var taskManager = new TaskManager(ApplicationPaths, _jsonSerializer, Logger, serverManager); + var packageManager = new PackageManager(); + LogManager.ReloadLogger(Kernel.Configuration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info); Logger.Info("Version {0} initializing", ApplicationVersion); var httpServer = ServerFactory.CreateServer(this, ProtobufSerializer, Logger, "Media Browser", "index.html"); - RegisterResources(taskManager, httpServer, networkManager, serverManager); + RegisterResources(taskManager, httpServer, networkManager, serverManager, packageManager); FindParts(taskManager, httpServer); } @@ -113,7 +116,7 @@ namespace MediaBrowser.ServerApplication /// /// Registers resources that classes will depend on /// - private void RegisterResources(ITaskManager taskManager, IHttpServer httpServer, INetworkManager networkManager, IServerManager serverManager) + private void RegisterResources(ITaskManager taskManager, IHttpServer httpServer, INetworkManager networkManager, IServerManager serverManager, IPackageManager packageManager) { RegisterSingleInstance(Kernel); RegisterSingleInstance(Kernel); @@ -137,8 +140,8 @@ namespace MediaBrowser.ServerApplication RegisterSingleInstance(httpServer, false); RegisterSingleInstance(networkManager); - RegisterSingleInstance(serverManager); + RegisterSingleInstance(packageManager); } /// From e15ff541c6cd3c26848b68708a3e51c7d6b512e6 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Wed, 27 Feb 2013 08:34:24 -0500 Subject: [PATCH 2/3] Move actual installation to PackageManager --- .../Updates/PackageManager.cs | 61 +++++++++++++- .../Updates/IPackageManager.cs | 17 +++- .../Updates/InstallationManager.cs | 80 ++++--------------- 3 files changed, 92 insertions(+), 66 deletions(-) diff --git a/MediaBrowser.Common.Implementations/Updates/PackageManager.cs b/MediaBrowser.Common.Implementations/Updates/PackageManager.cs index 3f09615e7..a9335dce0 100644 --- a/MediaBrowser.Common.Implementations/Updates/PackageManager.cs +++ b/MediaBrowser.Common.Implementations/Updates/PackageManager.cs @@ -1,12 +1,16 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Net; using MediaBrowser.Common.Security; using MediaBrowser.Common.Updates; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Updates; @@ -39,9 +43,62 @@ namespace MediaBrowser.Common.Implementations.Updates } - public Task InstallPackage(PackageVersionInfo package, CancellationToken cancellationToken) + public async Task InstallPackage(IHttpClient client, ILogger logger, ResourcePool resourcePool, IProgress progress, IZipClient zipClient, IApplicationPaths appPaths, PackageVersionInfo package, CancellationToken cancellationToken) { - throw new NotImplementedException(); + // Target based on if it is an archive or single assembly + // zip archives are assumed to contain directory structures relative to our ProgramDataPath + var isArchive = string.Equals(Path.GetExtension(package.sourceUrl), ".zip", StringComparison.OrdinalIgnoreCase); + var target = isArchive ? appPaths.ProgramDataPath : Path.Combine(appPaths.PluginsPath, package.targetFilename); + + // Download to temporary file so that, if interrupted, it won't destroy the existing installation + var tempFile = await client.GetTempFile(package.sourceUrl, resourcePool.Mb, cancellationToken, progress).ConfigureAwait(false); + + cancellationToken.ThrowIfCancellationRequested(); + + // Validate with a checksum + if (package.checksum != Guid.Empty) // support for legacy uploads for now + { + using (var crypto = new MD5CryptoServiceProvider()) + using (var stream = new BufferedStream(File.OpenRead(tempFile), 100000)) + { + var check = Guid.Parse(BitConverter.ToString(crypto.ComputeHash(stream)).Replace("-", String.Empty)); + if (check != package.checksum) + { + throw new ApplicationException(string.Format("Download validation failed for {0}. Probably corrupted during transfer.", package.name)); + } + } + } + + cancellationToken.ThrowIfCancellationRequested(); + + // Success - move it to the real target based on type + if (isArchive) + { + try + { + zipClient.ExtractAll(tempFile, target, true); + } + catch (IOException e) + { + logger.ErrorException("Error attempting to extract archive from {0} to {1}", e, tempFile, target); + throw; + } + + } + else + { + try + { + File.Copy(tempFile, target, true); + File.Delete(tempFile); + } + catch (IOException e) + { + logger.ErrorException("Error attempting to move file from {0} to {1}", e, tempFile, target); + throw; + } + } + } } } diff --git a/MediaBrowser.Common/Updates/IPackageManager.cs b/MediaBrowser.Common/Updates/IPackageManager.cs index d5a8a59b1..f3ca1d8cf 100644 --- a/MediaBrowser.Common/Updates/IPackageManager.cs +++ b/MediaBrowser.Common/Updates/IPackageManager.cs @@ -7,6 +7,8 @@ using System.Threading.Tasks; using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Net; using MediaBrowser.Common.Security; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Updates; @@ -34,9 +36,22 @@ namespace MediaBrowser.Common.Updates /// /// Installs a package. /// + /// + /// + /// + /// + /// + /// /// The package. /// The cancellation token. /// Task. - Task InstallPackage(PackageVersionInfo package, CancellationToken cancellationToken); + Task InstallPackage(IHttpClient client, + ILogger logger, + ResourcePool resourcePool, + IProgress progress, + IZipClient zipClient, + IApplicationPaths appPaths, + PackageVersionInfo package, + CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/Updates/InstallationManager.cs b/MediaBrowser.Controller/Updates/InstallationManager.cs index ebd644a82..7765b8aef 100644 --- a/MediaBrowser.Controller/Updates/InstallationManager.cs +++ b/MediaBrowser.Controller/Updates/InstallationManager.cs @@ -429,77 +429,31 @@ namespace MediaBrowser.Controller.Updates /// Task. private async Task InstallPackageInternal(PackageVersionInfo package, IProgress progress, CancellationToken cancellationToken) { - // Target based on if it is an archive or single assembly - // zip archives are assumed to contain directory structures relative to our ProgramDataPath - var isArchive = string.Equals(Path.GetExtension(package.sourceUrl), ".zip", StringComparison.OrdinalIgnoreCase); - var target = isArchive ? Kernel.ApplicationPaths.ProgramDataPath : Path.Combine(Kernel.ApplicationPaths.PluginsPath, package.targetFilename); + // Do the install + await _packageManager.InstallPackage(HttpClient, _logger, Kernel.ResourcePools, progress, ZipClient, Kernel.ApplicationPaths, package, cancellationToken).ConfigureAwait(false); - // Download to temporary file so that, if interrupted, it won't destroy the existing installation - var tempFile = await HttpClient.GetTempFile(package.sourceUrl, Kernel.ResourcePools.Mb, cancellationToken, progress).ConfigureAwait(false); - - cancellationToken.ThrowIfCancellationRequested(); - - // Validate with a checksum - if (package.checksum != Guid.Empty) // support for legacy uploads for now + // Do plugin-specific processing + if (!(Path.GetExtension(package.targetFilename) ?? "").Equals(".zip", StringComparison.OrdinalIgnoreCase)) { - using (var crypto = new MD5CryptoServiceProvider()) - using (var stream = new BufferedStream(File.OpenRead(tempFile), 100000)) + // Set last update time if we were installed before + var plugin = Kernel.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase)); + + if (plugin != null) { - var check = Guid.Parse(BitConverter.ToString(crypto.ComputeHash(stream)).Replace("-", String.Empty)); - if (check != package.checksum) + // Synchronize the UpdateClass value + if (plugin.Configuration.UpdateClass != package.classification) { - throw new ApplicationException(string.Format("Download validation failed for {0}. Probably corrupted during transfer.", package.name)); + plugin.Configuration.UpdateClass = package.classification; + plugin.SaveConfiguration(); } + + OnPluginUpdated(plugin, package); } - } - - cancellationToken.ThrowIfCancellationRequested(); - - // Success - move it to the real target based on type - if (isArchive) - { - try + else { - ZipClient.ExtractAll(tempFile, target, true); + OnPluginInstalled(package); } - catch (IOException e) - { - _logger.ErrorException("Error attempting to extract archive from {0} to {1}", e, tempFile, target); - throw; - } - - } - else - { - try - { - File.Copy(tempFile, target, true); - File.Delete(tempFile); - } - catch (IOException e) - { - _logger.ErrorException("Error attempting to move file from {0} to {1}", e, tempFile, target); - throw; - } - } - - // Set last update time if we were installed before - var plugin = Kernel.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase)); - - if (plugin != null) - { - // Synchronize the UpdateClass value - if (plugin.Configuration.UpdateClass != package.classification) - { - plugin.Configuration.UpdateClass = package.classification; - plugin.SaveConfiguration(); - } - - OnPluginUpdated(plugin, package); - } - else - { - OnPluginInstalled(package); + } } From 1d51ede06056a54099616d0f52fdf8150c510e50 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Wed, 27 Feb 2013 09:39:11 -0500 Subject: [PATCH 3/3] Persist the PackageManager on BaseApplicationHost --- .../BaseApplicationHost.cs | 9 ++++++++- MediaBrowser.ServerApplication/ApplicationHost.cs | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index e8acf2975..f7a889954 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.Implementations.Updates; +using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.Updates; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using SimpleInjector; @@ -36,6 +38,11 @@ namespace MediaBrowser.Common.Implementations /// protected readonly Container Container = new Container(); + /// + /// The package manager + /// + protected readonly IPackageManager PackageManager = new PackageManager(); + /// /// Gets assemblies that failed to load /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 2aa24dabf..7da565d57 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -82,15 +82,13 @@ namespace MediaBrowser.ServerApplication var taskManager = new TaskManager(ApplicationPaths, _jsonSerializer, Logger, serverManager); - var packageManager = new PackageManager(); - LogManager.ReloadLogger(Kernel.Configuration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info); Logger.Info("Version {0} initializing", ApplicationVersion); var httpServer = ServerFactory.CreateServer(this, ProtobufSerializer, Logger, "Media Browser", "index.html"); - RegisterResources(taskManager, httpServer, networkManager, serverManager, packageManager); + RegisterResources(taskManager, httpServer, networkManager, serverManager, PackageManager); FindParts(taskManager, httpServer); }