Download failure error.

This commit is contained in:
darkademic
2024-06-22 19:00:45 +01:00
committed by Gustas
parent 6dd076b27f
commit d450ef43c6
2 changed files with 11 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@@ -33,6 +34,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[FluentReference]
const string UnknownHost = "label-unknown-host";
[FluentReference]
const string DownloadFailed = "label-download-failed";
[FluentReference("host", "received", "suffix")]
const string DownloadingFrom = "label-downloading-from";
@@ -181,6 +185,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token);
if (response.StatusCode != HttpStatusCode.OK)
{
OnError(FluentProvider.GetString(DownloadFailed));
return;
}
using (var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, 8192, true))
{
await response.ReadAsStreamWithProgress(fileStream, OnDownloadProgress, token);