diff --git a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services.Implementation/ArchiSteamFarmServiceImpl.cs b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services.Implementation/ArchiSteamFarmServiceImpl.cs index c10b0f61b67..9af5d87d651 100644 --- a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services.Implementation/ArchiSteamFarmServiceImpl.cs +++ b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services.Implementation/ArchiSteamFarmServiceImpl.cs @@ -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? OnConsoleWirteLine; public TaskCompletionSource? ReadLineTask { get; set; } - private readonly AsyncLock @lock = new AsyncLock(); - - bool _IsReadPasswordLine; - public bool IsReadPasswordLine { get => _IsReadPasswordLine; @@ -44,8 +45,6 @@ public bool IsReadPasswordLine public Version CurrentVersion => SharedInfo.Version; - private bool isFirstStart = true; - public async Task StartAsync(string[]? args = null) { try @@ -194,25 +193,22 @@ string CalculateFileHash(string filePath) async Task 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; } }