Fixed: Errors logged during import when existing episode file is partial removed in the DB
Fixes #3159
This commit is contained in:
parent
4713eaffdb
commit
7dff9bc696
|
@ -302,5 +302,18 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||||
|
|
||||||
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
|
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_episode_file_is_null()
|
||||||
|
{
|
||||||
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
||||||
|
.All()
|
||||||
|
.With(e => e.EpisodeFileId = 1)
|
||||||
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(null))
|
||||||
|
.Build()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,5 +194,20 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile.Value, DeleteMediaFileReason.Upgrade), Times.Never());
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile.Value, DeleteMediaFileReason.Upgrade), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_import_if_existing_file_doesnt_exist_in_db()
|
||||||
|
{
|
||||||
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.EpisodeFileId = 1)
|
||||||
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(null))
|
||||||
|
.Build()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
||||||
|
|
||||||
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile.Value, It.IsAny<DeleteMediaFileReason>()), Times.Never());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,13 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
foreach (var episode in localEpisode.Episodes.Where(e => e.EpisodeFileId > 0))
|
foreach (var episode in localEpisode.Episodes.Where(e => e.EpisodeFileId > 0))
|
||||||
{
|
{
|
||||||
var episodeFile = episode.EpisodeFile.Value;
|
var episodeFile = episode.EpisodeFile.Value;
|
||||||
|
|
||||||
|
if (episodeFile == null)
|
||||||
|
{
|
||||||
|
_logger.Trace("Unable to get episode file details from the DB. EpisodeId: {0} EpisodeFileId: {1}", episode.Id, episode.EpisodeFileId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var qualityCompare = qualityComparer.Compare(localEpisode.Quality.Quality, episodeFile.Quality.Quality);
|
var qualityCompare = qualityComparer.Compare(localEpisode.Quality.Quality, episodeFile.Quality.Quality);
|
||||||
|
|
||||||
if (qualityCompare < 0)
|
if (qualityCompare < 0)
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
var existingFiles = localEpisode.Episodes
|
var existingFiles = localEpisode.Episodes
|
||||||
.Where(e => e.EpisodeFileId > 0)
|
.Where(e => e.EpisodeFileId > 0)
|
||||||
.Select(e => e.EpisodeFile.Value)
|
.Select(e => e.EpisodeFile.Value)
|
||||||
|
.Where(e => e != null)
|
||||||
.GroupBy(e => e.Id)
|
.GroupBy(e => e.Id)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue