Esempio n. 1
0
        public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrereleases = false)
        {
            try
            {
                using (UpdateManager updateManager = await GitHubUpdateManager(GitHubRepository, updateToPrereleases))
                {
                    UpdateInfo newUpdateInfo;
                    try
                    {
                        // UpdateApp CheckForUpdate will return value only if the app is squirrel installed
                        newUpdateInfo = await updateManager.CheckForUpdate().NonNull();
                    }
                    catch (Exception e) when(e is HttpRequestException || e is WebException || e is SocketException)
                    {
                        Logger.WoxError($"Check your connection and proxy settings to api.github.com.", e);
                        updateManager.Dispose();
                        return;
                    }

                    var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
                    var currentVersion    = Version.Parse(Constant.Version);

                    Logger.WoxInfo($"Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");

                    if (newReleaseVersion <= currentVersion)
                    {
                        if (!silentIfLatestVersion)
                        {
                            MessageBox.Show("You already have the latest Wox version");
                        }
                        updateManager.Dispose();
                        return;
                    }

                    try
                    {
                        await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
                    }
                    catch (Exception e) when(e is HttpRequestException || e is WebException || e is SocketException)
                    {
                        Logger.WoxError($"Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
                        updateManager.Dispose();
                        return;
                    }

                    await updateManager.ApplyReleases(newUpdateInfo);

                    if (DataLocation.PortableDataLocationInUse())
                    {
                        var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
                        FilesFolders.Copy(DataLocation.PortableDataPath, targetDestination);
                        if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination))
                        {
                            MessageBox.Show(string.Format("Wox was not able to move your user profile data to the new update version. Please manually" +
                                                          "move your profile data folder from {0} to {1}", DataLocation.PortableDataPath, targetDestination));
                        }
                    }
                    else
                    {
                        await updateManager.CreateUninstallerRegistryEntry();
                    }

                    var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());

                    MessageBox.Show(newVersionTips);
                    Logger.WoxInfo($"Update success:{newVersionTips}");
                }
            }
            catch (Exception e) when(e is HttpRequestException || e is WebException || e is SocketException)
            {
                Logger.WoxError($"Please check your connection and proxy settings to api.github.com.", e);
            }
        }
Esempio n. 2
0
 public void MoveUserDataFolder(string fromLocation, string toLocation)
 {
     FilesFolders.Copy(fromLocation, toLocation);
     VerifyUserDataAfterMove(fromLocation, toLocation);
 }
Esempio n. 3
0
        public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
        {
            UpdateManager updateManager;
            UpdateInfo    newUpdateInfo;

            if (!silentUpdate)
            {
                api.ShowMsg("Please wait...", "Checking for new update");
            }

            try
            {
                updateManager = await GitHubUpdateManager(GitHubRepository);
            }
            catch (Exception e) when(e is HttpRequestException || e is WebException || e is SocketException)
            {
                Log.Exception($"|Updater.UpdateApp|Please check your connection and proxy settings to api.github.com.", e);
                return;
            }

            try
            {
                // UpdateApp CheckForUpdate will return value only if the app is squirrel installed
                newUpdateInfo = await updateManager.CheckForUpdate().NonNull();
            }
            catch (Exception e) when(e is HttpRequestException || e is WebException || e is SocketException)
            {
                Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to api.github.com.", e);
                updateManager.Dispose();
                return;
            }

            var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
            var currentVersion    = Version.Parse(Constant.Version);

            Log.Info($"|Updater.UpdateApp|Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");

            if (newReleaseVersion <= currentVersion)
            {
                if (!silentUpdate)
                {
                    MessageBox.Show("You already have the latest Flow Launcher version");
                }
                updateManager.Dispose();
                return;
            }

            if (!silentUpdate)
            {
                api.ShowMsg("Update found", "Updating...");
            }

            try
            {
                await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
            }
            catch (Exception e) when(e is HttpRequestException || e is WebException || e is SocketException)
            {
                Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
                updateManager.Dispose();
                return;
            }

            await updateManager.ApplyReleases(newUpdateInfo);

            if (DataLocation.PortableDataLocationInUse())
            {
                var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
                FilesFolders.Copy(DataLocation.PortableDataPath, targetDestination);
                if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination))
                {
                    MessageBox.Show("Flow Launcher was not able to move your user profile data to the new update version. Please manually " +
                                    $"move your profile data folder from {DataLocation.PortableDataPath} to {targetDestination}");
                }
            }
            else
            {
                await updateManager.CreateUninstallerRegistryEntry();
            }

            var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());

            Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");

            // always dispose UpdateManager
            updateManager.Dispose();

            if (MessageBox.Show(newVersionTips, "New Update", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                UpdateManager.RestartApp(Constant.ApplicationFileName);
            }
        }