Fixed: Slow loading of files in Manage Episodes modal

Closes #5449
This commit is contained in:
Mark McDowall 2023-03-13 00:30:28 -07:00
parent 1f619e27f1
commit cd67671bc1
1 changed files with 4 additions and 3 deletions

View File

@ -81,8 +81,9 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
var series = _seriesService.GetSeries(seriesId); var series = _seriesService.GetSeries(seriesId);
var directoryInfo = new DirectoryInfo(series.Path); var directoryInfo = new DirectoryInfo(series.Path);
var seriesFiles = seasonNumber.HasValue ? _mediaFileService.GetFilesBySeason(seriesId, seasonNumber.Value) : _mediaFileService.GetFilesBySeries(seriesId); var seriesFiles = seasonNumber.HasValue ? _mediaFileService.GetFilesBySeason(seriesId, seasonNumber.Value) : _mediaFileService.GetFilesBySeries(seriesId);
var episodes = _episodeService.GetEpisodeBySeries(series.Id);
var items = seriesFiles.Select(episodeFile => MapItem(episodeFile, series, directoryInfo.Name)).ToList(); var items = seriesFiles.Select(episodeFile => MapItem(episodeFile, series, directoryInfo.Name, episodes)).ToList();
if (!seasonNumber.HasValue) if (!seasonNumber.HasValue)
{ {
@ -420,7 +421,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
return item; return item;
} }
private ManualImportItem MapItem(EpisodeFile episodeFile, Series series, string folderName) private ManualImportItem MapItem(EpisodeFile episodeFile, Series series, string folderName, List<Episode> episodes)
{ {
var item = new ManualImportItem(); var item = new ManualImportItem();
@ -430,7 +431,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
item.Name = Path.GetFileNameWithoutExtension(episodeFile.Path); item.Name = Path.GetFileNameWithoutExtension(episodeFile.Path);
item.Series = series; item.Series = series;
item.SeasonNumber = episodeFile.SeasonNumber; item.SeasonNumber = episodeFile.SeasonNumber;
item.Episodes = episodeFile.Episodes.Value; item.Episodes = episodes.Where(e => e.EpisodeFileId == episodeFile.Id).ToList();
item.ReleaseGroup = episodeFile.ReleaseGroup; item.ReleaseGroup = episodeFile.ReleaseGroup;
item.Quality = episodeFile.Quality; item.Quality = episodeFile.Quality;
item.Languages = episodeFile.Languages; item.Languages = episodeFile.Languages;