示例#1
0
        public static async Task <ReleaseEntry> UpdateApp(this IUpdateManager This, Action <int> progress = null)
        {
            progress = progress ?? (_ => {});

            This.Log().Info("Starting automatic update");

            var updateInfo = await This.ErrorIfThrows(() => This.CheckForUpdate(false, x => progress(x / 3)),
                                                      "Failed to check for updates");

            await This.ErrorIfThrows(() =>
                                     This.DownloadReleases(updateInfo.ReleasesToApply, x => progress(x / 3 + 33)),
                                     "Failed to download updates");

            await This.ErrorIfThrows(() =>
                                     This.ApplyReleases(updateInfo, x => progress(x / 3 + 66)),
                                     "Failed to apply updates");

            return(updateInfo.ReleasesToApply.MaxBy(x => x.Version).LastOrDefault());
        }
示例#2
0
        public static async Task <ReleaseEntry> UpdateApp(this IUpdateManager This, Action <int> progress = null)
        {
            progress = progress ?? (_ => { });
            This.Log().Info("Starting automatic update");

            bool ignoreDeltaUpdates = false;

retry:
            var updateInfo = default(UpdateInfo);

            try {
                updateInfo = await This.ErrorIfThrows(() => This.CheckForUpdate(ignoreDeltaUpdates, x => progress(x / 3)),
                                                      "Failed to check for updates");

                await This.ErrorIfThrows(() =>
                                         This.DownloadReleases(updateInfo.ReleasesToApply, x => progress(x / 3 + 33)),
                                         "Failed to download updates");

                await This.ErrorIfThrows(() =>
                                         This.ApplyReleases(updateInfo, x => progress(x / 3 + 66)),
                                         "Failed to apply updates");

                This.ErrorIfThrows(() =>
                                   This.UpdateUninstallerVersionRegistryEntry(),
                                   "Failed to set up uninstaller");
            } catch {
                if (ignoreDeltaUpdates == false)
                {
                    ignoreDeltaUpdates = true;
                    goto retry;
                }

                throw;
            }

            return(updateInfo.ReleasesToApply.Any() ?
                   updateInfo.ReleasesToApply.MaxBy(x => x.Version).Last() :
                   default(ReleaseEntry));
        }