mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #245 from taooceros/InformUserWhenUpdateFail
Inform user when checking update fail
This commit is contained in:
commit
5f345e150f
1 changed files with 43 additions and 64 deletions
|
|
@ -31,87 +31,66 @@ namespace Flow.Launcher.Core
|
||||||
|
|
||||||
public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
|
public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
|
||||||
{
|
{
|
||||||
UpdateManager updateManager;
|
|
||||||
UpdateInfo newUpdateInfo;
|
|
||||||
|
|
||||||
if (!silentUpdate)
|
|
||||||
api.ShowMsg("Please wait...", "Checking for new update");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
updateManager = await GitHubUpdateManager(GitHubRepository).ConfigureAwait(false);
|
UpdateInfo newUpdateInfo;
|
||||||
}
|
|
||||||
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
|
if (!silentUpdate)
|
||||||
{
|
api.ShowMsg("Please wait...", "Checking for new update");
|
||||||
Log.Exception($"|Updater.UpdateApp|Please check your connection and proxy settings to api.github.com.", e);
|
|
||||||
return;
|
using var updateManager = await GitHubUpdateManager(GitHubRepository).ConfigureAwait(false);
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
|
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
|
||||||
newUpdateInfo = await updateManager.CheckForUpdate().NonNull().ConfigureAwait(false);
|
newUpdateInfo = await updateManager.CheckForUpdate().NonNull().ConfigureAwait(false);
|
||||||
}
|
|
||||||
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 newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
|
||||||
var currentVersion = Version.Parse(Constant.Version);
|
var currentVersion = Version.Parse(Constant.Version);
|
||||||
|
|
||||||
Log.Info($"|Updater.UpdateApp|Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");
|
Log.Info($"|Updater.UpdateApp|Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");
|
||||||
|
|
||||||
|
if (newReleaseVersion <= currentVersion)
|
||||||
|
{
|
||||||
|
if (!silentUpdate)
|
||||||
|
MessageBox.Show("You already have the latest Flow Launcher version");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (newReleaseVersion <= currentVersion)
|
|
||||||
{
|
|
||||||
if (!silentUpdate)
|
if (!silentUpdate)
|
||||||
MessageBox.Show("You already have the latest Flow Launcher version");
|
api.ShowMsg("Update found", "Updating...");
|
||||||
updateManager.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!silentUpdate)
|
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply).ConfigureAwait(false);
|
||||||
api.ShowMsg("Update found", "Updating...");
|
|
||||||
|
|
||||||
try
|
await updateManager.ApplyReleases(newUpdateInfo).ConfigureAwait(false);
|
||||||
{
|
|
||||||
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
|
if (DataLocation.PortableDataLocationInUse())
|
||||||
|
{
|
||||||
|
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
|
||||||
|
FilesFolders.CopyAll(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().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());
|
||||||
|
|
||||||
|
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
|
||||||
|
|
||||||
|
if (MessageBox.Show(newVersionTips, "New Update", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
UpdateManager.RestartApp(Constant.ApplicationFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
|
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);
|
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
|
||||||
updateManager.Dispose();
|
api.ShowMsg("Update Failed", "Check your connection and try updating proxy settings to github-cloud.s3.amazonaws.com.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateManager.ApplyReleases(newUpdateInfo).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (DataLocation.PortableDataLocationInUse())
|
|
||||||
{
|
|
||||||
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
|
|
||||||
FilesFolders.CopyAll(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().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue