Skip to content

Commit

Permalink
🎨 fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzaz committed Nov 10, 2023
1 parent 9fffe84 commit 2b18e03
Showing 1 changed file with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,26 @@ public partial class ArchiSteamFarmServiceImpl : ReactiveObject, IArchiSteamFarm
{
const string TAG = "ArchiSteamFarmS";

private readonly AsyncLock @lock = new AsyncLock();

private bool isFirstStart = true;

private bool _IsReadPasswordLine;

private HttpClient _httpClient = new();

protected readonly IArchiSteamFarmWebApiService webApiService = IArchiSteamFarmWebApiService.Instance;

public ArchiSteamFarmServiceImpl()
{

}

public Process? ASFProcess { get; set; }

private Process? MainProcess;

public event Action<string>? OnConsoleWirteLine;

public TaskCompletionSource<string>? ReadLineTask { get; set; }

private readonly AsyncLock @lock = new AsyncLock();

bool _IsReadPasswordLine;

public bool IsReadPasswordLine
{
get => _IsReadPasswordLine;
Expand All @@ -44,8 +45,6 @@ public bool IsReadPasswordLine

public Version CurrentVersion => SharedInfo.Version;

private bool isFirstStart = true;

public async Task<bool> StartAsync(string[]? args = null)
{
try
Expand Down Expand Up @@ -194,25 +193,22 @@ string CalculateFileHash(string filePath)

async Task<bool> DownloadASFRelease(string downloadUrl, string savePath)
{
using (HttpClient httpClient = new HttpClient())
try
{
try
{
HttpResponseMessage response = await httpClient.GetAsync(downloadUrl);
HttpResponseMessage response = await _httpClient.GetAsync(downloadUrl);

// Ensure a successful response before proceeding
response.EnsureSuccessStatusCode();
// Ensure a successful response before proceeding
response.EnsureSuccessStatusCode();

using (var fileStream = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
await response.Content.CopyToAsync(fileStream);
}
}
catch (Exception ex)
using (var fileStream = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
return false;
await response.Content.CopyToAsync(fileStream);
}
}
catch (Exception ex)
{
return false;
}
return true;
}
}
Expand Down

0 comments on commit 2b18e03

Please sign in to comment.