protected override Dictionary <int, SafeList <string> > AllFolderLocations(bool manualToo, bool checkExist) { Dictionary <int, SafeList <string> > fld = new Dictionary <int, SafeList <string> >(); fld[0] = new SafeList <string>(); if (manualToo && UseManualLocations) { foreach (string kvp in ManualLocations.ToList()) { fld[0].Add(kvp.TrimSlash()); } } if (UseAutomaticFolders && !string.IsNullOrEmpty(AutomaticFolderRoot)) { string newName = AutoFolderNameForMovie(); if (!checkExist || Directory.Exists(newName)) { if (!fld[0].Contains(newName)) { fld[0].Add(newName.TrimSlash()); } } } return(fld); }
protected override void Check(ShowConfiguration si, DirFilesCache dfc, TVDoc.ScanSettings settings) { if (!si.DoMissingCheck && !si.DoRename) { return; // skip } Dictionary <int, SafeList <string> > flocs = si.AllProposedFolderLocations(); List <string> ignoredLocations = new List <string>(); foreach (int snum in si.GetSeasonKeys()) { // show MissingFolderAction for any folders that are missing // throw Exception if user cancels if (si.IgnoreSeasons.Contains(snum)) { continue; // ignore this season } if (snum == 0 && si.CountSpecials) { continue; // no specials season, they're merged into the seasons themselves } if (snum == 0 && TVSettings.Instance.IgnoreAllSpecials) { continue; } SafeList <string> folders = new SafeList <string>(); if (flocs.ContainsKey(snum)) { folders = flocs[snum]; } if (si.SeasonEpisodes[snum].All(episode => !MightWeProcess(episode, folders))) { //All episodes in this season are ignored continue; } if (folders.Count == 0 && si.AutoAddNewSeasons()) { // no folders defined for this season, and autoadd didn't find any, so suggest the autoadd folder name instead folders.Add(si.AutoFolderNameForSeason(snum)); } if (folders.Count == 0 && !si.AutoAddNewSeasons()) { // no folders defined for this season, and autoadd didn't find any, so suggest the autoadd folder name instead folders.Add(string.Empty); } CreateSeasonFolders(si, snum, folders, ignoredLocations, settings.Owner); } // for each snum }
private void ActionProcessor(object queuesIn) { try { if (!(queuesIn is ActionQueue[] queues)) { string message = $"Action Processor called with object that is not a ActionQueue[], instead called with a {queuesIn.GetType().FullName}"; Logger.Fatal(message); throw new ArgumentException(message); } foreach (ActionQueue queue in queues) { Logger.Info($"Setting up {queue}"); } try { actionWorkers = new SafeList <Thread>(); ExecuteQueues(queues); WaitForAllActionThreadsAndTidyUp(); } catch (ThreadAbortException) { if (!(actionWorkers is null)) { foreach (Thread t in actionWorkers) { t?.Abort(); } } WaitForAllActionThreadsAndTidyUp(); } } catch (ThreadAbortException) { //Ignore this Exception as we can be aborting threads } catch (Exception e) { Logger.Fatal(e, "Unhandled Exception in ActionProcessor"); if (!(actionWorkers is null)) { foreach (Thread t in actionWorkers) { t?.Abort(); } } } WaitForAllActionThreadsAndTidyUp(); }
public ShowSummary(TVDoc doc, UI parent) { MainWindow = parent; mDoc = doc; InitializeComponent(); showList = new SafeList <ShowSummaryData>(); Scan(); }
protected override void Check(ShowConfiguration si, DirFilesCache dfc, TVDoc.ScanSettings settings) { Dictionary <int, SafeList <string> > allFolders = si.AllExistngFolderLocations(); if (allFolders.Count == 0) // no folders defined for this show { return; // so, nothing to do. } //This is the code that will iterate over the DownloadIdentifiers and ask each to ensure that //it has all the required files for that show if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && allFolders.Any()) { Doc.TheActionList.Add(downloadIdentifiers.ProcessShow(si)); } //MS_TODO Put the banner refresh period into the settings file, we'll default to 3 months DateTime cutOff = DateTime.Now.AddMonths(-3); DateTime lastUpdate = si.BannersLastUpdatedOnDisk ?? DateTime.Now.AddMonths(-4); bool timeForBannerUpdate = cutOff.CompareTo(lastUpdate) == 1; if (TVSettings.Instance.NeedToDownloadBannerFile() && timeForBannerUpdate) { Doc.TheActionList.Add( downloadIdentifiers.ForceUpdateShow(DownloadIdentifier.DownloadType.downloadImage, si)); si.BannersLastUpdatedOnDisk = DateTime.Now; Doc.SetDirty(); } // process each folder for each season... foreach (int snum in si.ActiveSeasons.Keys()) { if (settings.Token.IsCancellationRequested) { return; } if (!allFolders.ContainsKey(snum)) { continue; } // all the folders for this particular season SafeList <string> folders = allFolders[snum]; CheckSeason(si, dfc, settings, snum, folders, timeForBannerUpdate); } // for each season of this show }
private void WaitForAllActionThreadsAndTidyUp() { if (actionWorkers != null) { foreach (Thread t in actionWorkers) { if (t.IsAlive) { t.Join(); } } } actionWorkers = null; }
private void CheckSeason([NotNull] ShowConfiguration si, DirFilesCache dfc, TVDoc.ScanSettings settings, int snum, [NotNull] SafeList <string> folders, bool timeForBannerUpdate) { bool folderNotDefined = folders.Count == 0; if (folderNotDefined && TVSettings.Instance.MissingCheck && !si.AutoAddNewSeasons()) { return; } // base folder: if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && si.AutoAddType != ShowConfiguration.AutomaticFolderType.none) { // main image for the folder itself Doc.TheActionList.Add(downloadIdentifiers.ProcessShow(si)); } foreach (string folder in folders) { CheckSeasonFolder(si, dfc, settings, snum, timeForBannerUpdate, folder); } // for each folder for this season of this show }