Пример #1
0
        public void CanFindDuplicates()
        {
            var duplication = new TestDuplication(_logger, _configuration, _applicationDiagnostics);
            var rootEntry   = new RootEntry();

            rootEntry.PopulateRoot($"{FolderName}\\");
            var rootEntries = new List <RootEntry> {
                rootEntry
            };

            duplication.ApplyMd5Checksum(rootEntries);
            // all 7 Files are partial hashed.
            Assert.That(duplication.DuplicationStatistcs().PartialHashes, Is.EqualTo(7));
            // all 7 files are full hashed because every file appears to have a duplicate at partial hash size.
            Assert.That(duplication.DuplicationStatistcs().FullHashes, Is.EqualTo(7));

            // need a new Duplication class() between ApplyMd5Checksum and GetDupePairs for valid operation.
            duplication = new TestDuplication(_logger, _configuration, _applicationDiagnostics);
            var dupes = duplication.GetDupePairs(rootEntries);

            Assert.That(dupes[0].Value.Count, Is.EqualTo(2)); // testset1 has 2 dupes
            Assert.That(dupes[1].Value.Count, Is.EqualTo(3)); // testset3 has 3 dupes

            Console.WriteLine();
            Console.WriteLine($"Dumping sets of duplicates count {dupes.Count}");
            foreach (var dupe in dupes)
            {
                Console.WriteLine($"set of dupes to {dupe.Key.Path}");
                foreach (var adupe in dupe.Value)
                {
                    Console.WriteLine($"dupe set file {adupe.FullPath}");
                }
            }
        }
Пример #2
0
        public void Scan(string name)
        {
            //TODO: wire up command properly
            var re = new RootEntry();

            re.PopulateRoot(name);
            Response = String.Format("Filecount: {0}", re.FileCount);
        }
Пример #3
0
        public static void CreateCache(string path)
        {
            var re = new RootEntry();

            try
            {
                re.SimpleScanCountEvent = ScanCountPrintDot;
                re.SimpleScanEndEvent   = ScanEndofEntries;
                re.ExceptionEvent       = PrintExceptions;

                re.PopulateRoot(path);
                if (Hack.BreakConsoleFlag)
                {
                    Console.WriteLine(" * Break key detected incomplete scan will not be saved.");
                    return;
                }

                var oldRoot = RootEntry.LoadDirCache(re.DefaultFileName);
                if (oldRoot != null)
                {
                    Console.WriteLine($"Found cache \"{re.DefaultFileName}\"");
                    Console.WriteLine("Updating hashs on new scan from found cache file.");
                    oldRoot.TraverseTreesCopyHash(re);
                }
                re.SortAllChildrenByPath();
                re.SaveRootEntry();
                var scanTimeSpan = (re.ScanEndUTC - re.ScanStartUTC);
                Console.WriteLine($"Scanned Path {re.Path}");
                Console.WriteLine($"Scan time {scanTimeSpan.TotalMilliseconds:0.00} msecs");
                Console.WriteLine($"Saved Scanned Path {re.DefaultFileName}");
                Console.WriteLine(
                    $"Files {re.FileEntryCount:0,0} Dirs {re.DirEntryCount:0,0} Total Size of Files {re.Size:0,0}");
            }
            catch (ArgumentException aex)
            {
                Console.WriteLine($"Error: {aex.Message}");
            }
        }