From d450ef43c66c96a7fbc18ba61800fce92696fc60 Mon Sep 17 00:00:00 2001 From: darkademic <41052878+darkademic@users.noreply.github.com> Date: Sat, 22 Jun 2024 19:00:45 +0100 Subject: [PATCH] Download failure error. --- .../Widgets/Logic/Installation/DownloadPackageLogic.cs | 10 ++++++++++ mods/common/languages/en.ftl | 1 + 2 files changed, 11 insertions(+) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs index 4a332535f7..3e41e6d380 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs @@ -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); diff --git a/mods/common/languages/en.ftl b/mods/common/languages/en.ftl index de537b506a..f25872b6b7 100644 --- a/mods/common/languages/en.ftl +++ b/mods/common/languages/en.ftl @@ -296,6 +296,7 @@ label-fetching-mirror-list = Fetching list of mirrors... label-downloading-from = Downloading from { $host } { $received } { $suffix } label-downloading-from-progress = Downloading from { $host } { $received } / { $total } { $suffix } ({ $progress }%) label-unknown-host = unknown host +label-download-failed = Download failed label-verifying-archive = Verifying archive... label-archive-validation-failed = Archive validation failed label-extracting-archive = Extracting...