// // ApplyReleases methods // List<string> installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release) { var pkg = new ZipPackage(Path.Combine(rootAppDirectory, "packages", release.Filename)); var target = getDirectoryForRelease(release.Version); // NB: This might happen if we got killed partially through applying the release if (target.Exists) { Utility.DeleteDirectory(target.FullName); } target.Create(); // Copy all of the files out of the lib/ dirs in the NuGet package // into our target App directory. // // NB: We sort this list in order to guarantee that if a Net20 // and a Net40 version of a DLL get shipped, we always end up // with the 4.0 version. pkg.GetFiles().Where(x => pathIsInFrameworkProfile(x, appFrameworkVersion)).OrderBy(x => x.Path) .ForEach(x => { var targetPath = Path.Combine(target.FullName, Path.GetFileName(x.Path)); var fi = fileSystem.GetFileInfo(targetPath); if (fi.Exists) fi.Delete(); using (var inf = x.GetStream()) using (var of = fi.Open(FileMode.CreateNew, FileAccess.Write)) { log.Info("Writing {0} to app directory", targetPath); inf.CopyTo(of); } }); var newCurrentVersion = updateInfo.FutureReleaseEntry.Version; // Perform post-install; clean up the previous version by asking it // which shortcuts to install, and nuking them. Then, run the app's // post install and set up shortcuts. return runPostInstallAndCleanup(newCurrentVersion, updateInfo.IsBootstrapping); }
public IObservable<List<string>> ApplyReleases(UpdateInfo updateInfo, IObserver<int> progress = null) { return acquireUpdateLock().SelectMany(_ => applyReleases(updateInfo, progress)); }
IObservable<List<string>> applyReleases(UpdateInfo updateInfo, IObserver<int> progress = null) { progress = progress ?? new Subject<int>(); // NB: It's important that we update the local releases file *only* // once the entire operation has completed, even though we technically // could do it after DownloadUpdates finishes. We do this so that if // we get interrupted / killed during this operation, we'll start over var ret = cleanDeadVersions(updateInfo.CurrentlyInstalledVersion != null ? updateInfo.CurrentlyInstalledVersion.Version : null) .Do(_ => progress.OnNext(10), progress.OnError) .SelectMany(_ => createFullPackagesFromDeltas(updateInfo.ReleasesToApply, updateInfo.CurrentlyInstalledVersion)) .Do(_ => progress.OnNext(50), progress.OnError) .SelectMany(release => Observable.Start(() => installPackageToAppDir(updateInfo, release), RxApp.TaskpoolScheduler)) .Do(_ => progress.OnNext(95), progress.OnError) .SelectMany(x => UpdateLocalReleasesFile().Select(_ => x)) .Do(_ => progress.OnNext(100)).Finally(() => progress.OnCompleted()) .PublishLast(); ret.Connect(); return ret; }
async Task<List<string>> applyReleases(UpdateInfo updateInfo, IObserver<int> progress = null) { progress = progress ?? new Subject<int>(); // NB: It's important that we update the local releases file *only* // once the entire operation has completed, even though we technically // could do it after DownloadUpdates finishes. We do this so that if // we get interrupted / killed during this operation, we'll start over var ret = default(List<string>); try { await cleanDeadVersions(updateInfo.CurrentlyInstalledVersion != null ? updateInfo.CurrentlyInstalledVersion.Version : null); progress.OnNext(10); var release = await createFullPackagesFromDeltas(updateInfo.ReleasesToApply, updateInfo.CurrentlyInstalledVersion); progress.OnNext(50); ret = await Observable.Start(() => installPackageToAppDir(updateInfo, release), RxApp.TaskpoolScheduler); progress.OnNext(95); await UpdateLocalReleasesFile(); progress.OnNext(100); } finally { progress.OnCompleted(); } return ret; }
// // ApplyReleases methods // List<string> installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release) { var pkg = new ZipPackage(Path.Combine(rootAppDirectory, "packages", release.Filename)); var target = getDirectoryForRelease(release.Version); // NB: This might happen if we got killed partially through applying the release if (target.Exists) { Utility.DeleteDirectory(target.FullName).Wait(); } target.Create(); // Copy all of the files out of the lib/ dirs in the NuGet package // into our target App directory. // // NB: We sort this list in order to guarantee that if a Net20 // and a Net40 version of a DLL get shipped, we always end up // with the 4.0 version. pkg.GetLibFiles().Where(x => pathIsInFrameworkProfile(x, appFrameworkVersion)) .OrderBy(x => x.Path) .ForEach(x => CopyFileToLocation(target, x)); pkg.GetContentFiles().ForEach(x => CopyFileToLocation(target, x)); var newCurrentVersion = updateInfo.FutureReleaseEntry.Version; // Perform post-install; clean up the previous version by asking it // which shortcuts to install, and nuking them. Then, run the app's // post install and set up shortcuts. return runPostInstallAndCleanup(newCurrentVersion, updateInfo.IsBootstrapping); }
public IObservable <List <string> > ApplyReleases(UpdateInfo updateInfo, IObserver <int> progress = null) { return(acquireUpdateLock().SelectMany(_ => applyReleases(updateInfo, progress))); }
/// <summary> /// Take an already downloaded set of releases and apply them, /// copying in the new files from the NuGet package and rewriting /// the application shortcuts. /// </summary> /// <param name="updateInfo">The UpdateInfo instance acquired from /// CheckForUpdate</param> /// <param name="progress">An Action which can be used to report Progress - /// will return values from 0-100</param> /// <returns>A list of EXEs that should be started if this is a new /// installation.</returns> public static Task<List<string>> ApplyReleasesAsync(this IUpdateManager This, UpdateInfo updateInfo, Action<int> progress) { var subj = new Subject<int>(); subj.Subscribe(progress, ex => { }); return This.ApplyReleases(updateInfo, subj).ToTask(); }
public IObservable<List<string>> ApplyReleases(UpdateInfo updateInfo, IObserver<int> progress = null) { Contract.Requires(updateInfo != null); return default(IObservable<List<string>>); }
public IObservable<Unit> ApplyReleases(UpdateInfo updateInfo) { Contract.Requires(updateInfo != null); return default(IObservable<Unit>); }
public IObservable <int> ApplyReleases(UpdateInfo updateInfo) { Contract.Requires(updateInfo != null); return(default(IObservable <int>)); }