Skip to content

Commit

Permalink
Update to v0.1.0-beta4 (#36)
Browse files Browse the repository at this point in the history
* Handle IOException separately in ApiProcedures

Caught IOException explicitly to provide more granular error handling. This allows to throw the IOException immediately while preserving the behavior for general exceptions. Adjusted throttler release comment to remove redundant text.

* Enable output redirection in ApiProcedures

This commit updates the process start information in ApiProcedures.cs to redirect standard output and error. It also sets UseShellExecute to false and CreateNoWindow to true for better process control and visibility.
  • Loading branch information
GamerVII-NET authored Aug 11, 2024
1 parent 0d334ab commit ec929a3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Gml.Client/Helpers/ApiProcedures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ private Process GetStartProcess(ProfileReadInfoDto profileDto, string installati
{
FileName = profileDto.JavaPath.Replace("{localPath}", installationDirectory),
Arguments = profileDto.Arguments,
WorkingDirectory = profilePath
WorkingDirectory = profilePath,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};


if (!File.Exists(process.StartInfo.FileName))
{
throw new FileNotFoundException("Java file not found", process.StartInfo.FileName);
Expand Down Expand Up @@ -278,7 +283,11 @@ private async Task DownloadFileWithRetry(string installationDirectory, ProfileFi
await DownloadFile(installationDirectory, file, throttler, cancellationToken);
return;
}
catch
catch(IOException ex)
{
throw;
}
catch(Exception ex)
{
if (attempt == 3)
throw;
Expand Down Expand Up @@ -334,13 +343,16 @@ private async Task DownloadFile(string installationDirectory, ProfileFileReadDto
_loadedFilesCount.OnNext(_finishedFilesCount);
Debug.WriteLine($"{_finishedFilesCount}/{_progressFilesCount}");
}
catch (IOException ex) {
throw;
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
throttler.Release(); // Возвращаем пройденное разрешение обратно в SemaphoreSlim.
throttler.Release();
}
}

Expand Down

0 comments on commit ec929a3

Please sign in to comment.