diff --git a/WowUp.Common/Models/Curse/CurseFile.cs b/WowUp.Common/Models/Curse/CurseFile.cs index bf52f0d5..d6f985f3 100644 --- a/WowUp.Common/Models/Curse/CurseFile.cs +++ b/WowUp.Common/Models/Curse/CurseFile.cs @@ -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; } diff --git a/WowUp.WPF/AddonProviders/CurseAddonProvider.cs b/WowUp.WPF/AddonProviders/CurseAddonProvider.cs index 0350c7c9..485627a9 100644 --- a/WowUp.WPF/AddonProviders/CurseAddonProvider.cs +++ b/WowUp.WPF/AddonProviders/CurseAddonProvider.cs @@ -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 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) diff --git a/WowUp.WPF/Assets/changelog.json b/WowUp.WPF/Assets/changelog.json index 1c4a1b65..e3c19a23 100644 --- a/WowUp.WPF/Assets/changelog.json +++ b/WowUp.WPF/Assets/changelog.json @@ -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." diff --git a/WowUp.WPF/WowUp.WPF.csproj b/WowUp.WPF/WowUp.WPF.csproj index 7c5ea8f3..4646af5d 100644 --- a/WowUp.WPF/WowUp.WPF.csproj +++ b/WowUp.WPF/WowUp.WPF.csproj @@ -10,7 +10,7 @@ WowUp Jliddev WowUp - 1.17.2 + 1.17.3 wowup_logo_512np_RRT_icon.ico jliddev https://wowup.io