First step of actual update

We will now need a bootstrapper to complete the update on startup
This commit is contained in:
Eric Reed 2013-02-28 16:03:59 -05:00
parent 4947db0e2a
commit 3657ef952d
4 changed files with 16 additions and 12 deletions

View File

@ -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<double>();
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;

View File

@ -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
}
}
}
}

View File

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

View File

@ -149,7 +149,7 @@ namespace MediaBrowser.ServerApplication
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
public bool CanSelfUpdate
{
get { return true; }
get { return Kernel.Configuration.EnableAutoUpdate; }
}
/// <summary>
@ -171,12 +171,14 @@ namespace MediaBrowser.ServerApplication
/// <summary>
/// Updates the application.
/// </summary>
/// <param name="package">The package that contains the update</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param>
/// <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>