mirror of
https://github.com/Readarr/Readarr.git
synced 2026-01-31 01:02:20 -05:00
Fixed: Edge case where import fails due to DB relationship mismatch
Signed-off-by: Robin Dadswell <robin@dadswell.email>
This commit is contained in:
@@ -96,17 +96,8 @@ public void should_be_reject_if_file_size_is_the_same()
|
||||
[Test]
|
||||
public void should_be_accepted_if_file_cannot_be_fetched()
|
||||
{
|
||||
_localTrack.Book = (Book)Builder<Book>.CreateListOfSize(1)
|
||||
.TheFirst(1)
|
||||
.With(e => e.Id = 1)
|
||||
.With(e => e.BookFiles = new LazyLoaded<List<BookFile>>(
|
||||
new List<BookFile>
|
||||
{
|
||||
new BookFile
|
||||
{
|
||||
Path = null
|
||||
}
|
||||
}))
|
||||
_localTrack.Book = Builder<Book>.CreateNew()
|
||||
.With(e => e.BookFiles = new LazyLoaded<List<BookFile>>((List<BookFile>)null))
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
|
||||
|
||||
@@ -15,9 +15,9 @@ public SameFileSpecification(Logger logger)
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Decision IsSatisfiedBy(LocalBook item, DownloadClientItem downloadClientItem)
|
||||
public Decision IsSatisfiedBy(LocalBook localBook, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
var bookFiles = item.Book?.BookFiles?.Value;
|
||||
var bookFiles = localBook.Book?.BookFiles?.Value;
|
||||
|
||||
if (bookFiles == null || !bookFiles.Any())
|
||||
{
|
||||
@@ -27,9 +27,17 @@ public Decision IsSatisfiedBy(LocalBook item, DownloadClientItem downloadClientI
|
||||
|
||||
foreach (var bookFile in bookFiles)
|
||||
{
|
||||
if (bookFile.Size == item.Size)
|
||||
if (bookFile == null)
|
||||
{
|
||||
_logger.Debug("'{0}' Has the same filesize as existing file", item.Path);
|
||||
var book = localBook.Book;
|
||||
_logger.Trace("Unable to get book file details from the DB. BookId: {0} BookFileId: {1}", book.Id, bookFile.Id);
|
||||
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
if (bookFile.Size == localBook.Size)
|
||||
{
|
||||
_logger.Debug("'{0}' Has the same filesize as existing file", localBook.Path);
|
||||
return Decision.Reject("Has the same filesize as existing file");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user