mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-02-28 10:44:25 +00:00
Fixed: Prevent books being added with AuthorMetadataId 0
(cherry picked from commit 0c227d0f21e3803c6293fd5988e48ea010483cad)
This commit is contained in:
@@ -63,6 +63,11 @@ namespace NzbDrone.Core.Books
|
||||
|
||||
public Book AddBook(Book newBook, bool doRefresh = true)
|
||||
{
|
||||
if (newBook.AuthorMetadataId == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot insert book with AuthorMetadataId = 0");
|
||||
}
|
||||
|
||||
_bookRepository.Upsert(newBook);
|
||||
|
||||
var editions = newBook.Editions.Value;
|
||||
@@ -244,6 +249,11 @@ namespace NzbDrone.Core.Books
|
||||
|
||||
public void InsertMany(List<Book> books)
|
||||
{
|
||||
if (books.Any(x => x.AuthorMetadataId == 0))
|
||||
{
|
||||
throw new InvalidOperationException("Cannot insert book with AuthorMetadataId = 0");
|
||||
}
|
||||
|
||||
_bookRepository.InsertMany(books);
|
||||
}
|
||||
|
||||
|
||||
@@ -374,6 +374,12 @@ namespace NzbDrone.Core.MediaFiles.BookImport
|
||||
if (dbBook == null)
|
||||
{
|
||||
_logger.Debug($"Adding remote book {book}");
|
||||
|
||||
if (book.AuthorMetadataId == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot insert book with AuthorMetadataId = 0");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
book.Added = DateTime.UtcNow;
|
||||
|
||||
@@ -747,6 +747,7 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
|
||||
|
||||
book.Author = author;
|
||||
book.AuthorMetadata = book.Author.Value.Metadata.Value;
|
||||
book.AuthorMetadataId = author.AuthorMetadataId;
|
||||
book.CleanTitle = book.Title.CleanAuthorName();
|
||||
}
|
||||
|
||||
@@ -833,6 +834,7 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
|
||||
|
||||
book.Author = author;
|
||||
book.AuthorMetadata = book.Author.Value.Metadata.Value;
|
||||
book.AuthorMetadataId = author.AuthorMetadataId;
|
||||
book.CleanTitle = book.Title.CleanAuthorName();
|
||||
book.SeriesLinks = MapSearchSeries(resource.Title, resource.BookTitleBare);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user