mirror of
https://github.com/Readarr/Readarr
synced 2026-01-02 05:37:45 +01:00
Fixed: Error refreshing author if manually added book edition has been removed from Goodreads
Fixes Sentry READARR-Z6
This commit is contained in:
parent
2a05112d7d
commit
474699b67d
1 changed files with 28 additions and 2 deletions
|
|
@ -137,10 +137,21 @@ public Author GetAuthorAndBooks(string foreignAuthorId, double minPopularity = 0
|
|||
if (existingAuthor != null)
|
||||
{
|
||||
var existingEditions = _editionService.GetEditionsByAuthor(existingAuthor.Id);
|
||||
var extraEditionIds = existingEditions.Select(x => x.ForeignEditionId).Except(books.Select(x => x.Editions.Value.First().ForeignEditionId));
|
||||
var extraEditionIds = existingEditions
|
||||
.Select(x => x.ForeignEditionId)
|
||||
.Except(books.Select(x => x.Editions.Value.First().ForeignEditionId))
|
||||
.ToList();
|
||||
|
||||
_logger.Debug($"Getting data for extra editions {extraEditionIds.ConcatToString()}");
|
||||
var extraEditions = extraEditionIds.Select(x => GetBookInfo(x));
|
||||
|
||||
var extraEditions = new List<Tuple<string, Book, List<AuthorMetadata>>>();
|
||||
foreach (var id in extraEditionIds)
|
||||
{
|
||||
if (TryGetBookInfo(id, true, out var result))
|
||||
{
|
||||
extraEditions.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
var bookDict = books.ToDictionary(x => x.ForeignBookId);
|
||||
foreach (var edition in extraEditions)
|
||||
|
|
@ -313,6 +324,21 @@ private HashSet<string> GetChangedBooksUncached(DateTime startTime)
|
|||
return null;
|
||||
}
|
||||
|
||||
private bool TryGetBookInfo(string foreignEditionId, bool useCache, out Tuple<string, Book, List<AuthorMetadata>> result)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = GetBookInfo(foreignEditionId, useCache);
|
||||
return true;
|
||||
}
|
||||
catch (BookNotFoundException e)
|
||||
{
|
||||
result = null;
|
||||
_logger.Warn(e, "Book not found");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Tuple<string, Book, List<AuthorMetadata>> GetBookInfo(string foreignEditionId, bool useCache = true)
|
||||
{
|
||||
_logger.Debug("Getting Book with GoodreadsId of {0}", foreignEditionId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue