Fixed: Edge case where import fails due to DB relationship mismatch

Closes #3243
pull/3249/head
Mark McDowall 5 years ago
parent bd9bded73b
commit 27f43569f5

@ -3,6 +3,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Marr.Data;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
using NzbDrone.Core.Parser.Model;
@ -92,5 +93,18 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse();
}
[Test]
public void should_be_accepted_if_file_cannot_be_fetched()
{
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
.TheFirst(1)
.With(e => e.EpisodeFileId = 1)
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>((EpisodeFile)null))
.Build()
.ToList();
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
}
}
}

@ -30,6 +30,16 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
return Decision.Accept();
}
var episodeFile = episodeFiles.First().Value;
if (episodeFile == null)
{
var episode = localEpisode.Episodes.First();
_logger.Trace("Unable to get episode file details from the DB. EpisodeId: {0} EpisodeFileId: {1}", episode.Id, episode.EpisodeFileId);
return Decision.Accept();
}
if (episodeFiles.First().Value.Size == localEpisode.Size)
{
_logger.Debug("'{0}' Has the same filesize as existing file", localEpisode.Path);

Loading…
Cancel
Save