Exemplo n.º 1
0
        protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> shows, TVDoc.ScanSettings settings)
        {
            returnActions   = new ItemList();
            showList        = MDoc.Library.GetShowItems(); //We ignore the current set of shows being scanned to be secrure that no files are deleted for unscanned shows
            currentSettings = settings;

            //for each directory in settings directory
            //for each file in directory
            //for each saved show (order by recent)
            //is file already available?
            //if so add show to list of files to be removed

            int totalDownloadFolders = TVSettings.Instance.DownloadFolders.Count;
            int c = 0;

            foreach (string dirPath in TVSettings.Instance.DownloadFolders.ToList())
            {
                UpdateStatus(c++, totalDownloadFolders, dirPath);

                if (!Directory.Exists(dirPath) || currentSettings.Token.IsCancellationRequested)
                {
                    continue;
                }

                filesThatMayBeNeeded = new List <FileInfo>();

                ReviewFilesInDownloadDirectory(dirPath);
                ReviewDirsInDownloadDirectory(dirPath);
            }

            ItemList removeActions = new ItemList();

            //Remove any missing items we are planning to resolve
            foreach (ActionCopyMoveRename acmr in returnActions.OfType <ActionCopyMoveRename>())
            {
                foreach (ItemMissing missingItem in MDoc.TheActionList.MissingItems())
                {
                    if (missingItem.Episode == acmr.Episode)
                    {
                        removeActions.Add(missingItem);
                    }
                }
            }

            MDoc.TheActionList.Replace(removeActions, returnActions);
        }