mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-06-09 15:52:37 -06:00
Update ExportAssetDownloader.cs
This commit is contained in:
parent
e7a9499601
commit
6df8443101
|
|
@ -64,15 +64,15 @@ internal partial class ExportAssetDownloader(string workingDirPath, bool reuse)
|
||||||
await Http.ResiliencePipeline.ExecuteAsync(
|
await Http.ResiliencePipeline.ExecuteAsync(
|
||||||
async innerCancellationToken =>
|
async innerCancellationToken =>
|
||||||
{
|
{
|
||||||
// Download the file.
|
// Download the file
|
||||||
// Use ResponseHeadersRead so the response body is streamed to disk instead of
|
|
||||||
// being fully buffered into memory first, which can cause an OutOfMemoryException
|
|
||||||
// on large attachments.
|
|
||||||
using var response = await Http.Client.GetAsync(
|
using var response = await Http.Client.GetAsync(
|
||||||
url,
|
url,
|
||||||
HttpCompletionOption.ResponseHeadersRead,
|
HttpCompletionOption.ResponseHeadersRead,
|
||||||
innerCancellationToken
|
innerCancellationToken
|
||||||
);
|
);
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
await using var output = File.Create(filePath);
|
await using var output = File.Create(filePath);
|
||||||
await response.Content.CopyToAsync(output, innerCancellationToken);
|
await response.Content.CopyToAsync(output, innerCancellationToken);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue