Squirrel.Windows icon indicating copy to clipboard operation
Squirrel.Windows copied to clipboard

Conditional update possible?

Open chromworks opened this issue 9 years ago • 2 comments

Is it possible to compare the latest release version (on GitHub) and the installed version? It seems I got crashes when my installed version is the latest one, and I want to around unnecessary update. Perhaps my implementation is bad. Below is the code. I feel the asynchronous task causes hang quite inconsistently. Any kind comment from an expert?

        task = Task.Run(async () => 
        {
            try
            {
                using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/chromworks/IEX_AutoUpdate"))
                {
                    await mgr.Result.UpdateApp();
                }
            }
            catch (Exception ex)
            {
               MessageBox.Show(ex.ToString());
            }

            try
            {
                using (var mgr = new UpdateManager("https://github.com/chromworks/IEX_AutoUpdate"))
                {
                    SquirrelAwareApp.HandleEvents(
                       onInitialInstall: v => mgr.CreateShortcutForThisExe(),
                       onAppUpdate: v => mgr.CreateShortcutForThisExe(),
                       onAppUninstall: v => mgr.RemoveShortcutForThisExe());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

        });

chromworks avatar Dec 28 '16 06:12 chromworks

Duplicate issue: #587

chromworks avatar Dec 28 '16 12:12 chromworks

Closing this out because it looks like lots of cases in #587 could be traced back to how checking for updates is managed:

Every example I've found of this is user error, you're checking for updates but closing the app before it completes. This is a bug in your app - killing the app while updates are applying is bad.

The code in this comment here is a good explainer of what your app should be doing to handle this situation:

https://github.com/Squirrel/Squirrel.Windows/issues/587#issuecomment-387799204

shiftkey avatar May 05 '19 14:05 shiftkey