Fix another CurseForge API error.

Add some better error logging around CurseForge scanning.
This commit is contained in:
jliddev
2020-10-02 14:19:24 -05:00
parent 7b52ebe51d
commit cffb838cf9
4 changed files with 29 additions and 14 deletions

View File

@@ -37,7 +37,7 @@ namespace WowUp.Common.Models.Curse
public object ExposeAsAlternative { get; set; }
public long PackageFingerprintId { get; set; }
public DateTime? GameVersionDateReleased { get; set; }
public long GameVersionMappingId { get; set; }
public long? GameVersionMappingId { get; set; }
public int GameVersionId { get; set; }
public int GameId { get; set; }
public bool IsServerPack { get; set; }

View File

@@ -1,5 +1,6 @@
using Flurl;
using Flurl.Http;
using Serilog;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -332,24 +333,34 @@ namespace WowUp.WPF.AddonProviders
private async Task MapAddonFolders(List<CurseScanResult> scanResults, WowClientType clientType)
{
//var fingerprintStr = string.Join(",", scanResults.Select(sf => sf.FolderScanner.Fingerprint));
var fingerprintResponse = await GetAddonsByFingerprints(scanResults.Select(sf => sf.FolderScanner.Fingerprint));
var fingerprints = scanResults.Select(sf => sf.FolderScanner.Fingerprint);
foreach (var scanResult in scanResults)
try
{
// Curse can deliver the wrong result sometimes, ensure the result matches the client type
scanResult.ExactMatch = fingerprintResponse.ExactMatches
.FirstOrDefault(exactMatch =>
IsClientType(exactMatch.File.GameVersionFlavor, clientType) &&
HasMatchingFingerprint(scanResult, exactMatch));
var fingerprintResponse = await GetAddonsByFingerprints(fingerprints);
// If the addon does not have an exact match, check the partial matches.
if (scanResult.ExactMatch == null)
foreach (var scanResult in scanResults)
{
scanResult.ExactMatch = fingerprintResponse.PartialMatches
.FirstOrDefault(partialMatch => partialMatch.File.Modules.Any(module => module.Fingerprint == scanResult.FolderScanner.Fingerprint));
// Curse can deliver the wrong result sometimes, ensure the result matches the client type
scanResult.ExactMatch = fingerprintResponse.ExactMatches
.FirstOrDefault(exactMatch =>
IsClientType(exactMatch.File.GameVersionFlavor, clientType) &&
HasMatchingFingerprint(scanResult, exactMatch));
// If the addon does not have an exact match, check the partial matches.
if (scanResult.ExactMatch == null)
{
scanResult.ExactMatch = fingerprintResponse.PartialMatches
.FirstOrDefault(partialMatch => partialMatch.File.Modules.Any(module => module.Fingerprint == scanResult.FolderScanner.Fingerprint));
}
}
}
catch(Exception ex)
{
Log.Error(ex, "Failed to map addon folders");
Log.Error($"Fingerprints\n{string.Join(",", fingerprints)}");
throw;
}
}
private bool HasMatchingFingerprint(CurseScanResult scanResult, CurseMatch exactMatch)

View File

@@ -1,5 +1,9 @@
{
"ChangeLogs": [
{
"Version": "1.17.3",
"Description": "Fix another CurseForge API error.\nAdd some better error logging around CurseForge scanning."
},
{
"Version": "1.17.2",
"Description": "Fix an issue with handling CurseForge API responses."

View File

@@ -10,7 +10,7 @@
<PackageId>WowUp</PackageId>
<Authors>Jliddev</Authors>
<Product>WowUp</Product>
<Version>1.17.2</Version>
<Version>1.17.3</Version>
<ApplicationIcon>wowup_logo_512np_RRT_icon.ico</ApplicationIcon>
<Copyright>jliddev</Copyright>
<PackageProjectUrl>https://wowup.io</PackageProjectUrl>