mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-23 15:27:03 -04:00
Fix another CurseForge API error.
Add some better error logging around CurseForge scanning.
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user