Fix narrators with null ASINs not importing (#1545 )

This commit is contained in:
MBucari
2026-01-08 19:57:47 -07:00
parent 068f37319f
commit 6f7cd4d5b5
2 changed files with 17 additions and 9 deletions

View File

@@ -28,6 +28,6 @@ public class ContributorSanitizer : ISanitizer
private static Person[]? SanitizePersonArray(Person?[]? contributors)
=> contributors
?.OfType<Person>()
.Where(c => !string.IsNullOrWhiteSpace(c.Asin) && !string.IsNullOrWhiteSpace(c.Name))
.Where(c => !string.IsNullOrWhiteSpace(c.Name))
.ToArray();
}

View File

@@ -69,16 +69,16 @@ namespace DtoImporterService
{
var qtyNew = 0;
foreach (var item in importItems)
{
if (!Cache.TryGetValue(item.DtoItem.ProductId, out var book))
foreach (var item in importItems)
{
book = createNewBook(item);
qtyNew++;
}
if (!Cache.TryGetValue(item.DtoItem.ProductId, out var book))
{
book = createNewBook(item);
qtyNew++;
}
updateBook(item, book);
}
updateBook(item, book);
}
return qtyNew;
}
@@ -160,6 +160,14 @@ namespace DtoImporterService
{
var item = importItem.DtoItem;
// Replacing narrators only became necessary to correct a bug introduced in 13.1.0
// which would no import narrators with null ASINs. Thus, affected books had the
// author listed as the narrators. This can probably be removed in the future.
// Bug went live in 13.1.0 on 2026/01/02. Today is 2026/01/08.
var narrators = item.Narrators?.DistinctBy(a => a.Name).Select(n => contributorImporter.Cache[n.Name]).ToArray();
if (narrators is not null && narrators.Length > 0)
book.ReplaceNarrators(narrators);
book.UpdateLengthInMinutes(item.LengthInMinutes);
// Update the book titles, since formatting can change