From 6df84431010315fca0c0e7bbb6b193ef1bf8ac3a Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Wed, 3 Jun 2026 14:09:06 +0300 Subject: [PATCH] Update ExportAssetDownloader.cs --- .../Exporting/ExportAssetDownloader.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs b/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs index badf681e..071616ec 100644 --- a/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs +++ b/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs @@ -64,15 +64,15 @@ internal partial class ExportAssetDownloader(string workingDirPath, bool reuse) await Http.ResiliencePipeline.ExecuteAsync( async innerCancellationToken => { - // 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. + // Download the file using var response = await Http.Client.GetAsync( url, HttpCompletionOption.ResponseHeadersRead, innerCancellationToken ); + + response.EnsureSuccessStatusCode(); + await using var output = File.Create(filePath); await response.Content.CopyToAsync(output, innerCancellationToken); },