Exemplo n.º 1
0
 public void FileSkipped(FileInfo fi, string reason)
 {
     lock (_lockStats)
     {
         numFilesSkipped++;
         ReportFiles.WriteExcludedInfo(true, fi.FullName, reason, fi.Extension);
     }
 }
Exemplo n.º 2
0
 public void HiddenSystemDirSkipped(DirectoryInfo di)
 {
     lock (_lockStats)
     {
         numHiddenSystemDirsSkipped++;
         ReportFiles.WriteExcludedInfo(false, di.FullName, "System or Hidden", "");
     }
 }
Exemplo n.º 3
0
 public void FileException(string fullName, string message)
 {
     lock (_lockStats)
     {
         numFileExceptions++;
         ReportFiles.WriteExcludedInfo(true, fullName, "Exception", message);
     }
 }
Exemplo n.º 4
0
 public void DirException(DirectoryInfo di, string message)
 {
     lock (_lockStats)
     {
         numDirExceptions++;
         ReportFiles.WriteExcludedInfo(false, di.FullName, "Exception", message);
     }
 }
Exemplo n.º 5
0
 public void SkipListDirSkipped(DirectoryInfo di)
 {
     lock (_lockStats)
     {
         numSkipListDirsSkipped++;
         ReportFiles.WriteExcludedInfo(false, di.FullName, "Dir in skip list", "");
     }
 }
Exemplo n.º 6
0
        public void DirectoryCompleted(DirectoryInfo di, string checksum, int numItemsScanned, int totalNumItems)
        {
            lock (_lockStats)
            {
                numDirectoriesCompleted++;

                ReportFiles.WriteDirectoryInfo(di, Program.baseName, numItemsScanned, totalNumItems, checksum, numDirectoriesCompleted);
            }
        }
Exemplo n.º 7
0
        public void FileCompleted(FileInfo fi, string checksum)
        {
            lock (_lockStats)
            {
                numFilesCompleted++;
                totalBytesCompleted += fi.Length;
                lastFileCompleted    = fi.FullName;

                ReportFiles.WriteFileInfo(fi, Program.baseName, checksum, numFilesCompleted);
            }
        }
Exemplo n.º 8
0
        public void DisplayFinalSummary()
        {
            // Wait for pending writes and then close files and erase last progress report
            lock (_lockStats)
            {
                ReportFiles.Close();
                Console.Write("{0}{1}{0}", backspaces, spaces);
            }

            double readSpeedbytesPerMin = (double)totalBytesScanned / (progressStopwatch.ElapsedMilliseconds / (MillisecondsPerSecond * SecondsPerMinute));

            Console.WriteLine("\n\nRun Complete - {0:N0} files and {1:N0} directories scanned in {2} - {3} at {4}/minute",
                              numFilesScanned, numDirectoriesScanned, TimerUtil.FormatMilliseconds(progressStopwatch.ElapsedMilliseconds), FileUtil.FormatByteSize(totalBytesScanned), FileUtil.FormatByteSize((long)readSpeedbytesPerMin));

            Console.WriteLine("   {0:N0} unique files copied ({1}), {2:N0} duplicate files found", numUniquesFound, FileUtil.FormatByteSize(totalBytesCopied), numDuplicatesFound);

            int totalFilesSkipped = 0, totalDirsSkipped = 0;

            totalFilesSkipped = numFilesSkipped + numFileExceptions;
            totalDirsSkipped  = numSkipListDirsSkipped + numHiddenSystemDirsSkipped + numDirExceptions;

            if (totalFilesSkipped > 0)
            {
                Console.WriteLine("\nTotal files skipped = {0:N0}", totalFilesSkipped);
                if (numFilesSkipped > 0)
                {
                    Console.WriteLine("    Skipped by rules: {0:N0}", numFilesSkipped);
                }
                if (numFileExceptions > 0)
                {
                    Console.WriteLine("    Files with exceptions: {0:N0}", numFileExceptions);
                }
            }

            if (totalDirsSkipped > 0)
            {
                Console.WriteLine("\nTotal directories skipped = {0:N0}", totalDirsSkipped);
                if (numSkipListDirsSkipped > 0)
                {
                    Console.WriteLine("    Directories in skip list: {0:N0}", numSkipListDirsSkipped);
                }
                if (numHiddenSystemDirsSkipped > 0)
                {
                    Console.WriteLine("    Hidden or System: {0:N0}", numHiddenSystemDirsSkipped);
                }
                if (numDirExceptions > 0)
                {
                    Console.WriteLine("    Directories with exceptions: {0:N0}", numDirExceptions);
                }
            }
        }
Exemplo n.º 9
0
        public void DuplicateFileCompleted(FileInfo fi, string originalFileFullPath, string checksum)
        {
            lock (_lockStats)
            {
                numFilesScanned++;
                totalBytesScanned += fi.Length;
                lastFileScanned    = "Dup: " + fi.FullName;
                lastFileWasUnique  = false;

                numDuplicatesFound++;

                ReportFiles.WriteDuplicateInfo(originalFileFullPath, fi, checksum, numDuplicatesFound);
            }
        }
Exemplo n.º 10
0
        public void UniqueFileCompleted(FileInfo fi, string copiedFileFullPath, string checksum, string category)
        {
            lock (_lockStats)
            {
                numFilesScanned++;
                totalBytesScanned += fi.Length;
                lastFileScanned    = "Unique: " + fi.FullName;
                lastFileWasUnique  = true;

                numUniquesFound++;
                totalBytesCopied += fi.Length;

                ReportFiles.WriteUniqueInfo(fi, copiedFileFullPath, checksum, numUniquesFound, category);

                ReportFiles.WriteFileInfo(fi, copiedFileFullPath, Program.baseName, checksum, numUniquesFound);
            }
        }
Exemplo n.º 11
0
        public static void Run(string baseName, string scanRootDir, int numThreads)
        {
            ReportFiles.Open(baseName, scanRootDir);

            fst = new ConcurrentFilesystemTraverser(scanRootDir);

            progress = new ReportProgress(numThreads);
            progress.Start();

            int nThreads = numThreads;

            Parallel.For(0, nThreads, i => { FileProcessor(i); });

            progress.Stop();
            progress.DisplayFinalSummary();

            // ReportFiles.Close(); // Files closed under lock by progress.DisplayFinalSummary()
        }
Exemplo n.º 12
0
        public static void ScanAndCopyUniques(string baseName, string scanRootDir, int numThreads, FileDB fileDB)
        {
            ReportFiles.Open(baseName, scanRootDir);

            CopyUniqueFile.SetSourcePathRoot(scanRootDir);

            fst = new ConcurrentFilesystemTraverser(scanRootDir);

            db         = fileDB;
            volumeName = baseName;

            progress = new ReportProgress(numThreads);
            progress.Start();

            int nThreads = numThreads;

            Parallel.For(0, nThreads, i => { FileProcessor(i); });

            progress.Stop();
            progress.DisplayFinalSummary();

            // ReportFiles.Close(); // Files closed under lock by progress.DisplayFinalSummary()
        }