Fixed async usage.

This commit is contained in:
Casper Sparre 2025-03-08 14:43:10 +01:00
parent 3a944c112d
commit 5488d9f80c
3 changed files with 13 additions and 12 deletions

View File

@ -2703,7 +2703,7 @@ public class APIHelper : IAPIHelper
using var response = await client.SendAsync(request);
Log.Debug($"CDRM Project Response (Attempt {attempt}): {response.Content.ReadAsStringAsync().Result}");
Log.Debug($"CDRM Project Response (Attempt {attempt}): {await response.Content.ReadAsStringAsync()}");
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();

View File

@ -855,7 +855,7 @@ public class DownloadHelper : IDownloadHelper
memoryStream.Seek(0, SeekOrigin.Begin);
MD5 md5 = MD5.Create();
byte[] hash = md5.ComputeHash(memoryStream);
byte[] hash = await md5.ComputeHashAsync(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
if (!avatarMD5Hashes.Contains(BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant()))
{
@ -898,7 +898,7 @@ public class DownloadHelper : IDownloadHelper
memoryStream.Seek(0, SeekOrigin.Begin);
MD5 md5 = MD5.Create();
byte[] hash = md5.ComputeHash(memoryStream);
byte[] hash = await md5.ComputeHashAsync(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
if (!headerMD5Hashes.Contains(BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant()))
{

View File

@ -44,15 +44,15 @@ public class Program
AuthHelper authHelper = new();
Task setupBrowserTask = authHelper.SetupBrowser(runningInDocker);
Task.Delay(1000).Wait();
await Task.Delay(1000);
if (!setupBrowserTask.IsCompleted)
{
AnsiConsole.MarkupLine($"[yellow]Downloading dependencies. Please wait ...[/]");
}
setupBrowserTask.Wait();
await setupBrowserTask;
Task<Auth?> getAuthTask = authHelper.GetAuthFromBrowser();
Task.Delay(5000).Wait();
await Task.Delay(5000);
if (!getAuthTask.IsCompleted)
{
if (runningInDocker)
@ -123,7 +123,7 @@ public class Program
AnsiConsole.Markup("[green]config.json located successfully!\n[/]");
try
{
string jsonText = File.ReadAllText("config.json");
string jsonText = await File.ReadAllTextAsync("config.json");
var jsonConfig = JsonConvert.DeserializeObject<Entities.Config>(jsonText);
if (jsonConfig != null)
@ -219,7 +219,7 @@ public class Program
hoconConfig.AppendLine($" LoggingLevel = \"{jsonConfig.LoggingLevel.ToString().ToLower()}\"");
hoconConfig.AppendLine("}");
File.WriteAllText("config.conf", hoconConfig.ToString());
await File.WriteAllTextAsync("config.conf", hoconConfig.ToString());
File.Delete("config.json");
AnsiConsole.Markup("[green]config.conf created successfully from config.json!\n[/]");
}
@ -245,7 +245,7 @@ public class Program
AnsiConsole.Markup("[green]config.conf located successfully!\n[/]");
try
{
string hoconText = File.ReadAllText("config.conf");
string hoconText = await File.ReadAllTextAsync("config.conf");
var hoconConfig = ConfigurationFactory.ParseString(hoconText);
@ -646,9 +646,10 @@ public class Program
AnsiConsole.Markup("[green]rules.json located successfully!\n[/]");
try
{
JsonConvert.DeserializeObject<DynamicRules>(File.ReadAllText("rules.json"));
string rulesJson = await File.ReadAllTextAsync("rules.json");
DynamicRules? dynamicRules = JsonConvert.DeserializeObject<DynamicRules>(rulesJson);
Log.Debug($"Rules.json: ");
Log.Debug(JsonConvert.SerializeObject(File.ReadAllText("rules.json"), Formatting.Indented));
Log.Debug(JsonConvert.SerializeObject(dynamicRules, Formatting.Indented));
}
catch (Exception e)
{
@ -2963,7 +2964,7 @@ public class Program
hoconConfig.AppendLine($" LoggingLevel = \"{newConfig.LoggingLevel.ToString().ToLower()}\"");
hoconConfig.AppendLine("}");
File.WriteAllText("config.conf", hoconConfig.ToString());
await File.WriteAllTextAsync("config.conf", hoconConfig.ToString());
string newConfigString = JsonConvert.SerializeObject(newConfig, Formatting.Indented);