Fixed: Orphaned episode file was preventing rename preview from functioning

This commit is contained in:
Mark McDowall 2014-02-23 13:37:21 -08:00
parent 4515c1d155
commit 828e8eb147
1 changed files with 7 additions and 0 deletions

View File

@ -75,6 +75,13 @@ namespace NzbDrone.Core.MediaFiles
foreach (var file in files)
{
var episodesInFile = episodes.Where(e => e.EpisodeFileId == file.Id).ToList();
if (!episodesInFile.Any())
{
_logger.Warn("File ({0}) is not linked to any episodes", file.Path);
continue;
}
var seasonNumber = episodesInFile.First().SeasonNumber;
var newName = _filenameBuilder.BuildFilename(episodesInFile, series, file);
var newPath = _filenameBuilder.BuildFilePath(series, seasonNumber, newName, Path.GetExtension(file.Path));