Beispiel #1
0
        public 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
            return Observable.Using(_ => acquireUpdateLock().ToTask(), (dontcare, ct) => {
                var obs = cleanDeadVersions(updateInfo.CurrentlyInstalledVersion != null ? updateInfo.CurrentlyInstalledVersion.Version : null)
                    .Do(_ => progress.OnNext(10))
                    .SelectMany(_ => createFullPackagesFromDeltas(updateInfo.ReleasesToApply, updateInfo.CurrentlyInstalledVersion))
                    .Do(_ => progress.OnNext(50))
                    .Select(release => installPackageToAppDir(updateInfo, release))
                    .Do(_ => progress.OnNext(95))
                    .SelectMany(ret => UpdateLocalReleasesFile().Select(_ => ret))
                    .Finally(() => progress.OnCompleted())
                    .PublishLast();

                obs.Connect();

                // NB: This overload of Using is high as a kite.
                var tcs = new TaskCompletionSource<IObservable<List<string>>>();
                tcs.SetResult(obs);
                return tcs.Task;
            });
        }
Beispiel #2
0
        //
        // ApplyReleases methods
        //

        List<string> installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release)
        {
            var pkg = new ZipPackage(Path.Combine(updateInfo.PackageDirectory, 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.
            log.Info("Writing files to app directory: {0}", target.FullName);

            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)
 {
     Contract.Requires(updateInfo != null);
     return(default(IObservable <List <string> >));
 }
        /// <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>>);
 }
 /// <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();
 }
Beispiel #7
0
 public IObservable <List <string> > ApplyReleases(UpdateInfo updateInfo, IObserver <int> progress = null)
 {
     return(acquireUpdateLock().SelectMany(_ => applyReleases(updateInfo, progress).ToObservable()));
 }