示例#1
0
        public void Find(IEnumerable <RootEntry> rootEntries)
        {
            if (VisitorFunc == null)
            {
                return;
            }

            int[] limitCount = { LimitResultCount };
            if (ProgressFunc == null || ProgressModifier == 0)
            {   // dummy func and huge progressModifier so wont call progressFunc anyway.
                ProgressFunc     = delegate { };
                ProgressModifier = int.MaxValue;
            }

            // ReSharper disable PossibleMultipleEnumeration
            ProgressEnd = rootEntries.TotalFileEntries();
            // ReSharper restore PossibleMultipleEnumeration
            ProgressFunc(_progressCount[0], ProgressEnd);        // Start of process Progress report.
            PatternMatcher = GetPatternMatcher();

            var findFunc = GetFindFunc(_progressCount, limitCount);

            // ReSharper disable PossibleMultipleEnumeration
            CommonEntry.TraverseTreePair(rootEntries, findFunc);
            ProgressFunc(_progressCount[0], ProgressEnd);        // end of Progress
            // ReSharper restore PossibleMultipleEnumeration
        }
示例#2
0
        public IDictionary <long, List <PairDirEntry> > GetSizePairs(IEnumerable <RootEntry> rootEntries)
        {
            CommonEntry.TraverseTreePair(rootEntries, FindMatchesOnFileSize2);
            _logger.LogDebug("Post TraverseMatchOnFileSize: {0}, dupeDictCount {1}", _applicationDiagnostics.GetMemoryAllocated().FormatAsBytes(), _duplicateFileSize.Count);

            //Remove the single values from the dictionary.  DOESNT SEEM TO CLEAR MEMORY ??? GC Force?
            _duplicateFileSize.Where(kvp => kvp.Value.Count == 1).ToList().ForEach(x => _duplicateFileSize.Remove(x.Key));
            _logger.LogDebug("Deleted entries from dictionary: {0}, dupeDictCount {1}", _applicationDiagnostics.GetMemoryAllocated().FormatAsBytes(), _duplicateFileSize.Count);
            return(_duplicateFileSize);
        }
示例#3
0
        public IList <KeyValuePair <DirEntry, List <PairDirEntry> > > GetDupePairs(IEnumerable <RootEntry> rootEntries)
        {
            CommonEntry.TraverseTreePair(rootEntries, BuildDuplicateList);
            var moreThanOneFile = _duplicateFile.Where(d => d.Value.Count > 1).ToList();

            _logger.LogInfo("Count of list of all hashes of files with same sizes {0}",
                            _duplicateFile.Count);
            _logger.LogInfo("Count of list of all hashes of files with same sizes where more than 1 of that hash {0}",
                            moreThanOneFile.Count);
            return(moreThanOneFile);
        }
示例#4
0
        private void CheckDupesAndCompleteFullHash(IEnumerable <RootEntry> rootEntries)
        {
            _logger.LogDebug(string.Empty);
            _logger.LogDebug("Checking duplicates and completing full hash.");
            CommonEntry.TraverseTreePair(rootEntries, BuildDuplicateListIncludePartialHash);

            var founddupes          = _duplicateFile.Where(d => d.Value.Count > 1);
            var totalEntriesInDupes = founddupes.Sum(x => x.Value.Count);
            var longestListLength   = founddupes.Any() ? founddupes.Max(x => x.Value.Count) : 0;

            _logger.LogInfo("Found {0} duplication collections.", founddupes.Count());
            _logger.LogInfo("Total files found with at least 1 other file duplicate {0}",
                            totalEntriesInDupes);
            _logger.LogInfo("Longest list of duplicate files is {0}", longestListLength);

            foreach (var keyValuePair in founddupes)
            {
                foreach (var pairDirEntry in keyValuePair.Value)
                {
                    _dirEntriesRequiringFullHashing.Add(pairDirEntry.ChildDE);
                }
            }
            CommonEntry.TraverseTreePair(rootEntries, CalculateFullMD5Hash);
        }