示例#1
0
        private static ReturnCode FixDir(RvFile dir, bool lastSelected, List <RvFile> fileProcessQueue, ref int totalFixed, ref int reportedFixed, Stopwatch cacheSaveTimer)
        {
            //Debug.WriteLine(dir.FullName);
            bool thisSelected = lastSelected;

            if (dir.Tree != null)
            {
                thisSelected = dir.Tree.Checked == RvTreeRow.TreeSelect.Selected;
            }

            List <RvFile> lstToProcess = new List <RvFile>();

            for (int j = 0; j < dir.ChildCount; j++)
            {
                lstToProcess.Add(dir.Child(j));
            }

            foreach (RvFile child in lstToProcess)
            {
                ReturnCode returnCode = FixBase(child, thisSelected, fileProcessQueue, ref totalFixed, ref reportedFixed, cacheSaveTimer);
                if (returnCode != ReturnCode.Good)
                {
                    return(returnCode);
                }

                while (fileProcessQueue.Any())
                {
                    returnCode = FixBase(fileProcessQueue[0], true, fileProcessQueue, ref totalFixed, ref reportedFixed, cacheSaveTimer);
                    if (returnCode != ReturnCode.Good)
                    {
                        return(returnCode);
                    }
                    fileProcessQueue.RemoveAt(0);
                }

                if (totalFixed != reportedFixed)
                {
                    Report.ReportProgress(new bgwProgress(totalFixed));
                    reportedFixed = totalFixed;
                }
                if (Report.CancellationPending())
                {
                    break;
                }
            }
            // here we check to see if the directory we just scanned should be deleted
            FixFileUtils.CheckDeleteFile(dir);
            return(ReturnCode.Good);
        }
示例#2
0
        public static void PerformFixes(ThreadWorker thWrk)
        {
            try
            {
                Stopwatch cacheSaveTimer = new Stopwatch();
                cacheSaveTimer.Reset();
                if (Settings.rvSettings.CacheSaveTimerEnabled)
                {
                    cacheSaveTimer.Start();
                }

                if (!Report.Set(thWrk))
                {
                    return;
                }


                Report.ReportProgress(new bgwText("Fixing Files"));

                int totalFixes    = 0;
                int totalFixed    = 0;
                int reportedFixed = 0;
                for (int i = 0; i < DB.DirTree.ChildCount; i++)
                {
                    RvFile tdir = DB.DirTree.Child(i);
                    totalFixes += CountFixDir(tdir, tdir.Tree.Checked == RvTreeRow.TreeSelect.Selected);
                }
                Report.ReportProgress(new bgwSetRange(totalFixes));

                List <RvFile> fileProcessQueue = new List <RvFile>();

                for (int i = 0; i < DB.DirTree.ChildCount; i++)
                {
                    RvFile     tdir       = DB.DirTree.Child(i);
                    ReturnCode returnCode = FixDir(tdir, tdir.Tree.Checked == RvTreeRow.TreeSelect.Selected, fileProcessQueue, ref totalFixed, ref reportedFixed, cacheSaveTimer);
                    if (returnCode != ReturnCode.Good)
                    {
                        RepairStatus.ReportStatusReset(DB.DirTree);
                        break;
                    }

                    if (Report.CancellationPending())
                    {
                        break;
                    }
                }

                Report.ReportProgress(new bgwText("Updating Cache"));
                DB.Write();
                Report.ReportProgress(new bgwText("Complete"));

                Report.Set(null);
            }
            catch (Exception exc)
            {
                ReportError.UnhandledExceptionHandler(exc);

                Report.ReportProgress(new bgwText("Updating Cache"));

                DB.Write();
                Report.ReportProgress(new bgwText("Complete"));


                Report.Set(null);
            }
        }