LukePulverenti 12 years ago
commit 6cb135f89c

@ -80,11 +80,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
progress.Report(10); progress.Report(10);
if (!updateInfo.IsUpdateAvailable) //>>> FOR TESTING
{ //if (!updateInfo.IsUpdateAvailable)
progress.Report(100); //{
return; // progress.Report(100);
} // return;
//}
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -97,7 +98,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
innerProgress = new Progress<double>(); innerProgress = new Progress<double>();
innerProgress.ProgressChanged += innerProgressHandler; innerProgress.ProgressChanged += innerProgressHandler;
await _appHost.UpdateApplication(cancellationToken, innerProgress).ConfigureAwait(false); await _appHost.UpdateApplication(updateInfo.Package, cancellationToken, innerProgress).ConfigureAwait(false);
// Release the event handler // Release the event handler
innerProgress.ProgressChanged -= innerProgressHandler; innerProgress.ProgressChanged -= innerProgressHandler;

@ -47,8 +47,8 @@ namespace MediaBrowser.Common.Implementations.Updates
{ {
// Target based on if it is an archive or single assembly // Target based on if it is an archive or single assembly
// zip archives are assumed to contain directory structures relative to our ProgramDataPath // zip archives are assumed to contain directory structures relative to our ProgramDataPath
var isArchive = string.Equals(Path.GetExtension(package.sourceUrl), ".zip", StringComparison.OrdinalIgnoreCase); var isArchive = string.Equals(Path.GetExtension(package.targetFilename), ".zip", StringComparison.OrdinalIgnoreCase);
var target = isArchive ? appPaths.ProgramDataPath : Path.Combine(appPaths.PluginsPath, package.targetFilename); 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 // 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); var tempFile = await client.GetTempFile(package.sourceUrl, resourcePool.Mb, cancellationToken, progress).ConfigureAwait(false);
@ -100,5 +100,6 @@ namespace MediaBrowser.Common.Implementations.Updates
} }
} }
} }
} }

@ -70,7 +70,7 @@ namespace MediaBrowser.Common.Kernel
/// Updates the application. /// Updates the application.
/// </summary> /// </summary>
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task UpdateApplication(CancellationToken cancellationToken, IProgress<double> progress); Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress);
/// <summary> /// <summary>
/// Creates an instance of type and resolves all constructor dependancies /// Creates an instance of type and resolves all constructor dependancies

@ -149,7 +149,7 @@ namespace MediaBrowser.ServerApplication
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
public bool CanSelfUpdate public bool CanSelfUpdate
{ {
get { return true; } get { return Kernel.Configuration.EnableAutoUpdate; }
} }
/// <summary> /// <summary>
@ -171,12 +171,14 @@ namespace MediaBrowser.ServerApplication
/// <summary> /// <summary>
/// Updates the application. /// Updates the application.
/// </summary> /// </summary>
/// <param name="package">The package that contains the update</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param> /// <param name="progress">The progress.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
public Task UpdateApplication(CancellationToken cancellationToken, IProgress<double> progress) public Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress)
{ {
return new ApplicationUpdater().UpdateApplication(cancellationToken, progress); var pkgManager = Resolve<IPackageManager>();
return pkgManager.InstallPackage(Resolve<IHttpClient>(), Resolve<ILogger>(), Kernel.ResourcePools, progress, Resolve<IZipClient>(), Kernel.ApplicationPaths, package, cancellationToken);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save