Fixed app not launching properly

This commit is contained in:
Jeddunk 2021-01-01 14:53:02 +01:00
parent 717960c6b5
commit 201e122e8b
3 changed files with 18 additions and 14 deletions

View File

@ -64,7 +64,7 @@ namespace auto_creamapi.Services
MyLogger.Log.Information("Getting content from API..."); MyLogger.Log.Information("Getting content from API...");
var client = new HttpClient(); var client = new HttpClient();
var httpCall = client.GetAsync(SteamUri); var httpCall = client.GetAsync(SteamUri);
var response = await httpCall; var response = await httpCall.ConfigureAwait(false);
var readAsStringAsync = response.Content.ReadAsStringAsync(); var readAsStringAsync = response.Content.ReadAsStringAsync();
var responseBody = await readAsStringAsync; var responseBody = await readAsStringAsync;
MyLogger.Log.Information("Got content from API successfully. Writing to file..."); MyLogger.Log.Information("Got content from API successfully. Writing to file...");

View File

@ -15,6 +15,7 @@ namespace auto_creamapi.Services
public void Save(); public void Save();
public void CheckIfDllExistsAtTarget(); public void CheckIfDllExistsAtTarget();
public bool CreamApiApplied(); public bool CreamApiApplied();
public bool CreamApiApplied(string arch);
} }
public class CreamDllService : ICreamDllService public class CreamDllService : ICreamDllService
@ -23,7 +24,7 @@ namespace auto_creamapi.Services
private const string X64Arch = "x64"; private const string X64Arch = "x64";
private static readonly string HashPath = Path.Combine(Directory.GetCurrentDirectory(), "cream_api.md5"); private static readonly string HashPath = Path.Combine(Directory.GetCurrentDirectory(), "cream_api.md5");
private readonly Dictionary<string, CreamDll> _creamDlls = new Dictionary<string, CreamDll>(); private Dictionary<string, CreamDll> _creamDlls;
private bool _x64Exists; private bool _x64Exists;
private bool _x86Exists; private bool _x86Exists;
@ -33,9 +34,11 @@ namespace auto_creamapi.Services
public async Task Initialize() public async Task Initialize()
{ {
MyLogger.Log.Debug("CreamDllService: Initialize begin"); MyLogger.Log.Debug("CreamDllService: Initialize begin");
_creamDlls = new Dictionary<string, CreamDll>
_creamDlls.Add(X86Arch, new CreamDll("steam_api.dll", "steam_api_o.dll")); {
_creamDlls.Add(X64Arch, new CreamDll("steam_api64.dll", "steam_api64_o.dll")); {X86Arch, new CreamDll("steam_api.dll", "steam_api_o.dll")},
{X64Arch, new CreamDll("steam_api64.dll", "steam_api64_o.dll")}
};
if (!File.Exists(HashPath)) if (!File.Exists(HashPath))
{ {
@ -45,7 +48,7 @@ namespace auto_creamapi.Services
{ {
$"{_creamDlls[X86Arch].Hash} {_creamDlls[X86Arch].Filename}", $"{_creamDlls[X86Arch].Hash} {_creamDlls[X86Arch].Filename}",
$"{_creamDlls[X64Arch].Hash} {_creamDlls[X64Arch].Filename}" $"{_creamDlls[X64Arch].Hash} {_creamDlls[X64Arch].Filename}"
}); }).ConfigureAwait(false);
} }
MyLogger.Log.Debug("CreamDllService: Initialize end"); MyLogger.Log.Debug("CreamDllService: Initialize end");
@ -59,12 +62,12 @@ namespace auto_creamapi.Services
public void CheckIfDllExistsAtTarget() public void CheckIfDllExistsAtTarget()
{ {
var x86file = Path.Combine(TargetPath, "steam_api.dll"); var x86File = Path.Combine(TargetPath, "steam_api.dll");
var x64file = Path.Combine(TargetPath, "steam_api64.dll"); var x64File = Path.Combine(TargetPath, "steam_api64.dll");
_x86Exists = File.Exists(x86file); _x86Exists = File.Exists(x86File);
_x64Exists = File.Exists(x64file); _x64Exists = File.Exists(x64File);
if (_x86Exists) MyLogger.Log.Information($"x86 SteamAPI DLL found: {x86file}"); if (_x86Exists) MyLogger.Log.Information($"x86 SteamAPI DLL found: {x86File}");
if (_x64Exists) MyLogger.Log.Information($"x64 SteamAPI DLL found: {x64file}"); if (_x64Exists) MyLogger.Log.Information($"x64 SteamAPI DLL found: {x64File}");
} }
public bool CreamApiApplied() public bool CreamApiApplied()
@ -98,7 +101,7 @@ namespace auto_creamapi.Services
return a & b; return a & b;
} }
private string GetHash(string filename) private static string GetHash(string filename)
{ {
if (File.Exists(filename)) if (File.Exists(filename))
{ {

View File

@ -71,7 +71,8 @@ namespace auto_creamapi.ViewModels
var filename = await download; var filename = await download;
/*var extract = _download.Extract(filename); /*var extract = _download.Extract(filename);
await extract;*/ await extract;*/
await Task.Run(() => _download.Extract(filename)); var extract = Task.Run(() => _download.Extract(filename));
await extract.ConfigureAwait(false);
_token.Dispose(); _token.Dispose();
await _navigationService.Close(this); await _navigationService.Close(this);
} }