Show error message if Goldberg could not be downloaded/extracted, prompting the user to do so manually.
Try to skip getting DLC from SteamDB on error.
This commit is contained in:
parent
19f460d12d
commit
8e62880e23
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using GoldbergGUI.Core.Models;
|
||||
using GoldbergGUI.Core.Utils;
|
||||
using MvvmCross.Logging;
|
||||
@ -85,7 +86,10 @@ namespace GoldbergGUI.Core.Services
|
||||
_log = log;
|
||||
|
||||
var download = await Download().ConfigureAwait(false);
|
||||
if (download) await Extract(_goldbergZipPath).ConfigureAwait(false);
|
||||
if (download)
|
||||
{
|
||||
await Extract(_goldbergZipPath).ConfigureAwait(false);
|
||||
}
|
||||
return await GetGlobalSettings().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@ -378,6 +382,8 @@ namespace GoldbergGUI.Core.Services
|
||||
}
|
||||
|
||||
private async Task StartDownload(string downloadUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new HttpClient();
|
||||
_log.Debug(downloadUrl);
|
||||
@ -390,6 +396,13 @@ namespace GoldbergGUI.Core.Services
|
||||
_log.Info("Download finished!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage();
|
||||
_log.Error(e.ToString);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Empty subfolder ./goldberg/
|
||||
// Extract all from archive to subfolder ./goldberg/
|
||||
@ -397,13 +410,34 @@ namespace GoldbergGUI.Core.Services
|
||||
{
|
||||
_log.Debug("Start extraction...");
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(_goldbergPath, true);
|
||||
ZipFile.ExtractToDirectory(archivePath, _goldbergPath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ShowErrorMessage();
|
||||
_log.Error(e.ToString);
|
||||
Environment.Exit(1);
|
||||
// throw;
|
||||
}
|
||||
}).ConfigureAwait(false);
|
||||
_log.Debug("Extraction done!");
|
||||
}
|
||||
|
||||
private void ShowErrorMessage()
|
||||
{
|
||||
if (Directory.Exists(_goldbergPath))
|
||||
{
|
||||
Directory.Delete(_goldbergPath, true);
|
||||
}
|
||||
Directory.CreateDirectory(_goldbergPath);
|
||||
MessageBox.Show("Could not setup Goldberg Emulator!\n" +
|
||||
"Please download it manually and extract its content into the \"goldberg\" subfolder!");
|
||||
}
|
||||
|
||||
// https://gitlab.com/Mr_Goldberg/goldberg_emulator/-/blob/master/generate_interfaces_file.cpp
|
||||
// (maybe) check DLL date first
|
||||
public async Task GenerateInterfacesFile(string filePath)
|
||||
|
@ -218,6 +218,8 @@ namespace GoldbergGUI.Core.Services
|
||||
|
||||
// ReSharper disable once InvertIf
|
||||
if (useSteamDb)
|
||||
{
|
||||
try
|
||||
{
|
||||
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
|
||||
|
||||
@ -268,6 +270,12 @@ namespace GoldbergGUI.Core.Services
|
||||
_log.Error("Could not get DLC from SteamDB!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error("Could not get DLC from SteamDB!");
|
||||
_log.Error(e.ToString);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user