Skip to content

Commit

Permalink
Optimise memory load of redistributable download (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz authored Jan 22, 2025
1 parent de05da4 commit de88333
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/CSnakes.Runtime/Locators/RedistributableLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,11 @@ protected override string GetLibPythonPath(string folder, bool freeThreaded = fa
private static async Task<string> DownloadFileToTempDirectoryAsync(string fileUrl)
{
using HttpClient client = new();
using HttpResponseMessage response = await client.GetAsync(fileUrl);
response.EnsureSuccessStatusCode();
using var contentStream = await client.GetStreamAsync(fileUrl);

string tempFilePath = Path.GetTempFileName();
using FileStream fileStream = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write, FileShare.None);
await response.Content.CopyToAsync(fileStream);
await contentStream.CopyToAsync(fileStream);

return tempFilePath;
}
Expand Down

0 comments on commit de88333

Please sign in to comment.