mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Show better error message when auto-updating fails
This commit is contained in:
parent
af14c19334
commit
cd0547664c
@ -589,39 +589,51 @@ namespace Bloxstrap
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetStatus($"Getting the latest {App.ProjectName}...");
|
SetStatus($"Getting the latest {App.ProjectName}...");
|
||||||
|
|
||||||
// 64-bit is always the first option
|
try
|
||||||
GithubReleaseAsset asset = releaseInfo.Assets[0];
|
|
||||||
string downloadLocation = Path.Combine(Paths.LocalAppData, "Temp", asset.Name);
|
|
||||||
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Downloading {releaseInfo.TagName}...");
|
|
||||||
|
|
||||||
if (!File.Exists(downloadLocation))
|
|
||||||
{
|
{
|
||||||
var response = await App.HttpClient.GetAsync(asset.BrowserDownloadUrl);
|
// 64-bit is always the first option
|
||||||
|
GithubReleaseAsset asset = releaseInfo.Assets[0];
|
||||||
|
string downloadLocation = Path.Combine(Paths.LocalAppData, "Temp", asset.Name);
|
||||||
|
|
||||||
await using var fileStream = new FileStream(downloadLocation, FileMode.CreateNew);
|
App.Logger.WriteLine(LOG_IDENT, $"Downloading {releaseInfo.TagName}...");
|
||||||
await response.Content.CopyToAsync(fileStream);
|
|
||||||
|
if (!File.Exists(downloadLocation))
|
||||||
|
{
|
||||||
|
var response = await App.HttpClient.GetAsync(asset.BrowserDownloadUrl);
|
||||||
|
|
||||||
|
await using var fileStream = new FileStream(downloadLocation, FileMode.CreateNew);
|
||||||
|
await response.Content.CopyToAsync(fileStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Logger.WriteLine(LOG_IDENT, $"Starting {releaseInfo.TagName}...");
|
||||||
|
|
||||||
|
ProcessStartInfo startInfo = new()
|
||||||
|
{
|
||||||
|
FileName = downloadLocation,
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (string arg in App.LaunchArgs)
|
||||||
|
startInfo.ArgumentList.Add(arg);
|
||||||
|
|
||||||
|
App.Settings.Save();
|
||||||
|
App.ShouldSaveConfigs = false;
|
||||||
|
|
||||||
|
Process.Start(startInfo);
|
||||||
|
|
||||||
|
App.Terminate();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Starting {releaseInfo.TagName}...");
|
|
||||||
|
|
||||||
ProcessStartInfo startInfo = new()
|
|
||||||
{
|
{
|
||||||
FileName = downloadLocation,
|
App.Logger.WriteLine(LOG_IDENT, "An exception occurred when running the auto-updater");
|
||||||
};
|
App.Logger.WriteException(LOG_IDENT, ex);
|
||||||
|
|
||||||
foreach (string arg in App.LaunchArgs)
|
Controls.ShowMessageBox(
|
||||||
startInfo.ArgumentList.Add(arg);
|
$"Bloxstrap was unable to auto-update to {releaseInfo.TagName}. Please update it manually by downloading and running the latest release from the GitHub page.",
|
||||||
|
MessageBoxImage.Information
|
||||||
App.Settings.Save();
|
);
|
||||||
App.ShouldSaveConfigs = false;
|
}
|
||||||
|
|
||||||
Process.Start(startInfo);
|
|
||||||
|
|
||||||
App.Terminate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Uninstall()
|
private void Uninstall()
|
||||||
|
Loading…
Reference in New Issue
Block a user