private static bool EpisodeNeeded([NotNull] ShowConfiguration si, DirFilesCache dfc, int seasF, int epF, [NotNull] FileSystemInfo fi) { if (si is null) { throw new ArgumentNullException(nameof(si)); } if (fi is null) { throw new ArgumentNullException(nameof(fi)); } try { CachedSeriesInfo s = si.CachedShow; if (s is null) { //We have not downloaded the cachedSeries, so have to assume that we need the episode/file return(true); } ProcessedEpisode pep = si.GetEpisode(seasF, epF); foreach (FileInfo testFileInfo in FindEpOnDisk(dfc, si, pep)) { //We will check that the file that is found is not the one we are testing if (fi.FullName == testFileInfo.FullName) { continue; } //We have found another file that matches return(false); } } catch (ShowConfiguration.EpisodeNotFoundException) { //Ignore exception, we may need the file return(true); } return(true); }
private static Action SetupDirectoryRemoval([NotNull] DirectoryInfo di, [NotNull] IReadOnlyList <ShowConfiguration> matchingShows) { ShowConfiguration si = matchingShows[0]; //Choose the first cachedSeries FinderHelper.FindSeasEp(di, out int seasF, out int epF, si, out TVSettings.FilenameProcessorRE _); CachedSeriesInfo s = si.CachedShow; if (s is null) { throw new ArgumentNullException(nameof(s)); } ProcessedEpisode pep = si.GetEpisode(seasF, epF); LOGGER.Info( $"Removing {di.FullName} as it matches {si.ShowName} and no episodes are needed"); return(new ActionDeleteDirectory(di, pep, TVSettings.Instance.Tidyup)); }