diff --git a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs
index e9e389a7..98b0341a 100644
--- a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs
+++ b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using Wabbajack.Common;
@@ -92,7 +93,7 @@ namespace Wabbajack.Lib.Downloaders
}
;
- if (stream.IsFaulted)
+ if (stream.IsFaulted || response.StatusCode != HttpStatusCode.OK)
{
Utils.Log($"While downloading {Url} - {stream.Exception.ExceptionToString()}");
return false;
diff --git a/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs b/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs
index 9405a61a..d59b6446 100644
--- a/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs
+++ b/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs
@@ -5,10 +5,13 @@ using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
using Wabbajack.Common;
+using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib.Validation;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
+using File = System.IO.File;
using Game = Wabbajack.Common.Game;
namespace Wabbajack.Lib.ModListRegistry
@@ -40,6 +43,9 @@ namespace Wabbajack.Lib.ModListRegistry
///
public string LogoUrl { get; set; }
+ [YamlIgnore]
+ public BitmapSource Logo { get; set; }
+
///
/// Download URL
///
@@ -57,5 +63,14 @@ namespace Wabbajack.Lib.ModListRegistry
return d.Deserialize>(result);
}
}
+
+ public ModlistMetadata LoadLogo()
+ {
+ // Todo: look at making this stream based instead of requiring a file
+ var temp_file = Path.GetTempFileName();
+ DownloadDispatcher.ResolveArchive(LogoUrl).Download(new Archive {Name = LogoUrl}, temp_file);
+ Logo = new BitmapImage(new Uri(temp_file));
+ return this;
+ }
}
}
diff --git a/Wabbajack.Test/ModlistMetadataTests.cs b/Wabbajack.Test/ModlistMetadataTests.cs
index abc4e629..0b09aa7c 100644
--- a/Wabbajack.Test/ModlistMetadataTests.cs
+++ b/Wabbajack.Test/ModlistMetadataTests.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib.ModListRegistry;
namespace Wabbajack.Test
@@ -17,5 +18,21 @@ namespace Wabbajack.Test
var modlists = ModlistMetadata.LoadFromGithub();
Assert.IsTrue(modlists.Count > 0);
}
+
+ [TestMethod]
+ public void VerifyLogoURLs()
+ {
+ var modlists = ModlistMetadata.LoadFromGithub();
+
+ foreach (var modlist in modlists)
+ {
+ var logo_state = DownloadDispatcher.ResolveArchive(modlist.LogoUrl);
+ Assert.IsNotNull(logo_state);
+ Assert.IsTrue(logo_state.Verify(), $"{modlist.LogoUrl} is not valid");
+
+ modlist.LoadLogo();
+ Assert.IsNotNull(modlist.Logo);
+ }
+ }
}
}
diff --git a/Wabbajack.Test/Wabbajack.Test.csproj b/Wabbajack.Test/Wabbajack.Test.csproj
index 064fd383..b3632231 100644
--- a/Wabbajack.Test/Wabbajack.Test.csproj
+++ b/Wabbajack.Test/Wabbajack.Test.csproj
@@ -68,6 +68,7 @@
..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
+