diff --git a/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs b/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs index 9705edf0..28dc4f1f 100644 --- a/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs +++ b/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs @@ -3,8 +3,6 @@ using BUTR.Site.NexusMods.ServerClient; using BUTR.Site.NexusMods.Shared.Helpers; -using HtmlAgilityPack; - using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -50,9 +48,7 @@ static string GetException(ExceptionModel? exception, bool inner = false) => exc var response = await client.SendAsync(request); var content = await response.Content.ReadAsStringAsync(); - var document = new HtmlDocument(); - document.LoadHtml(content.Replace("", "NULL")); - return (id, CrashReportParser.ParseLegacyHtml(10, document, content)); + return (id, CrashReportParser.ParseLegacyHtml(10, content)); } if (_crashReports is null) diff --git a/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj b/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj index 4f1c467f..c3bc9c3b 100644 --- a/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj +++ b/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj @@ -18,7 +18,6 @@ - diff --git a/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs b/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs index b1434697..37b0bdbc 100644 --- a/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs +++ b/src/BUTR.Site.NexusMods.Server/Jobs/CrashReportProcessorJob.cs @@ -58,7 +58,7 @@ public CrashReportProcessorJob(ILogger logger, IService _serviceScopeFactory = serviceScopeFactory ?? throw new ArgumentNullException(nameof(serviceScopeFactory)); } - private static async Task DownloadCrashReportsAsync(TenantId tenant, IAsyncEnumerable requests, CrashReporterClient client, ChannelWriter httpResultChannel, CancellationToken ct) + private static async Task DownloadCrashReportsAsync(TenantId tenant, IAsyncEnumerable requests, ILogger logger, CrashReporterClient client, ChannelWriter httpResultChannel, CancellationToken ct) { var options = new ParallelOptions { CancellationToken = ct, MaxDegreeOfParallelism = ParallelCount }; await Parallel.ForEachAsync(requests, options, async (entry, ct2) => @@ -70,9 +70,15 @@ await Parallel.ForEachAsync(requests, options, async (entry, ct2) => { var content = await client.GetCrashReportAsync(fileId, ct2); - var document = new HtmlDocument(); - document.LoadHtml(content.Replace("", "NULL")); - model = CrashReportParser.ParseLegacyHtml(version, document, content); + try + { + model = CrashReportParser.ParseLegacyHtml(version, content); + } + catch (Exception e) + { + logger.LogError(e, "Failed to parse {FileId}", fileId); + throw; + } } else { @@ -253,7 +259,7 @@ static string GetException(ExceptionModel? exception, bool inner = false) => exc // Disposing the DBContext will save the data } - private static async Task HandleFileIdDatesAsync(TenantId tenant, IServiceProvider serviceProvider, CrashReporterClient client, IAsyncEnumerable requests, CancellationToken ct) + private static async Task HandleFileIdDatesAsync(TenantId tenant, IServiceProvider serviceProvider, ILogger logger, CrashReporterClient client, IAsyncEnumerable requests, CancellationToken ct) { var options = serviceProvider.GetRequiredService>().Value; var httpResultChannel = Channel.CreateBounded(ParallelCount); @@ -263,7 +269,7 @@ private static async Task HandleFileIdDatesAsync(TenantId tenant, IServiceProvid await Task.WhenAll(new Task[] { - DownloadCrashReportsAsync(tenant, requests, client, httpResultChannel, ct), + DownloadCrashReportsAsync(tenant, requests, logger, client, httpResultChannel, ct), FilterCrashReportsAsync(tenant, serviceProvider, httpResultChannel, databaseResultChannel, linkedCrashReportsChannel, ignoredCrashReportsChannel, ct), WriteIgnoredToDatabaseAsync(tenant, serviceProvider, ignoredCrashReportsChannel, ct), WriteLinkedToDatabaseAsync(tenant, serviceProvider, linkedCrashReportsChannel, ct), @@ -301,7 +307,7 @@ public async Task Execute(IJobExecutionContext context) fileIds.ExceptWith(await dbContextRead.CrashReportToFileIds.Where(x => fileIds.Contains(x.FileId)).Select(x => x.FileId).ToListAsync(ct)); if (fileIds.Count == 0) continue; - await HandleFileIdDatesAsync(tenant, scope.ServiceProvider, client, client.GetCrashReportMetadataAsync(fileIds, ct).OfType(), ct); + await HandleFileIdDatesAsync(tenant, scope.ServiceProvider, _logger, client, client.GetCrashReportMetadataAsync(fileIds, ct).OfType(), ct); processed += fileIds.Count; } }