diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs index 18fcdbbda..e6436639e 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs @@ -80,11 +80,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks progress.Report(10); - if (!updateInfo.IsUpdateAvailable) - { - progress.Report(100); - return; - } + //>>> FOR TESTING + //if (!updateInfo.IsUpdateAvailable) + //{ + // progress.Report(100); + // return; + //} cancellationToken.ThrowIfCancellationRequested(); @@ -97,7 +98,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks innerProgress = new Progress(); innerProgress.ProgressChanged += innerProgressHandler; - await _appHost.UpdateApplication(cancellationToken, innerProgress).ConfigureAwait(false); + await _appHost.UpdateApplication(updateInfo.Package, cancellationToken, innerProgress).ConfigureAwait(false); // Release the event handler innerProgress.ProgressChanged -= innerProgressHandler; diff --git a/MediaBrowser.Common.Implementations/Updates/PackageManager.cs b/MediaBrowser.Common.Implementations/Updates/PackageManager.cs index a9335dce0..f53f503db 100644 --- a/MediaBrowser.Common.Implementations/Updates/PackageManager.cs +++ b/MediaBrowser.Common.Implementations/Updates/PackageManager.cs @@ -47,8 +47,8 @@ namespace MediaBrowser.Common.Implementations.Updates { // 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); + var isArchive = string.Equals(Path.GetExtension(package.targetFilename), ".zip", StringComparison.OrdinalIgnoreCase); + var target = isArchive ? appPaths.TempUpdatePath : 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); @@ -100,5 +100,6 @@ namespace MediaBrowser.Common.Implementations.Updates } } + } } diff --git a/MediaBrowser.Common/Kernel/IApplicationHost.cs b/MediaBrowser.Common/Kernel/IApplicationHost.cs index 2d2d0a217..bb007ddff 100644 --- a/MediaBrowser.Common/Kernel/IApplicationHost.cs +++ b/MediaBrowser.Common/Kernel/IApplicationHost.cs @@ -70,7 +70,7 @@ namespace MediaBrowser.Common.Kernel /// Updates the application. /// /// Task. - Task UpdateApplication(CancellationToken cancellationToken, IProgress progress); + Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress progress); /// /// Creates an instance of type and resolves all constructor dependancies diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index f350b2885..894f7cc75 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -149,7 +149,7 @@ namespace MediaBrowser.ServerApplication /// true if this instance can self update; otherwise, false. public bool CanSelfUpdate { - get { return true; } + get { return Kernel.Configuration.EnableAutoUpdate; } } /// @@ -171,12 +171,14 @@ namespace MediaBrowser.ServerApplication /// /// Updates the application. /// + /// The package that contains the update /// The cancellation token. /// The progress. /// Task. - public Task UpdateApplication(CancellationToken cancellationToken, IProgress progress) + public Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress progress) { - return new ApplicationUpdater().UpdateApplication(cancellationToken, progress); + var pkgManager = Resolve(); + return pkgManager.InstallPackage(Resolve(), Resolve(), Kernel.ResourcePools, progress, Resolve(), Kernel.ApplicationPaths, package, cancellationToken); } ///