Download failure error.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user