Esempio n. 1
0
 private static void UpdateContentSignatures(MemoryFileDatabase database, FileDescriptor rootDescriptor)
 {
     Console.WriteLine("Updating content signatures");
     var progressTracker = new ConsoleProgressTracker(database.GetAllDescriptors().Count());
     var contentCrawler = new FileCrawler(new NullFileDatabase(), new RevisitDescriptorProvider(),
                                          new SampleSignatureGenerator(new SHA1HashGenerator()), progressTracker);
     var contentTimer = Stopwatch.StartNew();
     contentCrawler.ScanDirectory(rootDescriptor);
     contentTimer.Stop();
     var descriptorCount = database.GetAllDescriptors().Count();
     //            PrintDescriptorTree(rootDescriptor, descriptor => descriptor.ContentHash);
     //            PrintDuplicates(database, descriptor => descriptor.ContentHash);
     Console.WriteLine("Calculated content signature for {0} entries in {1}. {2} files per second", descriptorCount,
                       contentTimer.Elapsed, 1000 * descriptorCount / contentTimer.ElapsedMilliseconds);
 }
Esempio n. 2
0
 private static FileDescriptor StatScanFolder(MemoryFileDatabase database, string baseFolder)
 {
     var volumeInfo = new VolumeInfo(baseFolder);
     Console.WriteLine($"Name = {volumeInfo.VolumeName}, Serial = {volumeInfo.SerialNumber}");
     database.RootInfo = new RootInfo
     {
         RootPath = baseFolder,
         VolumeId = volumeInfo.SerialNumber,
         VolumeLabel = volumeInfo.VolumeName
     };
     var progressTracker = new ConsoleProgressTracker();
     var signatureGenerator = new StatSignatureGenerator(new SHA1HashGenerator());
     var crawler = new FileCrawler(database, new SystemFileDescriptorProvider(), signatureGenerator, progressTracker);
     var scanTimer = Stopwatch.StartNew();
     var rootDescriptor = crawler.ScanDirectory(baseFolder);
     scanTimer.Stop();
     var descriptorCount = database.GetAllDescriptors().Count();
     Console.WriteLine("Scanned {0} entries in {1}. {2} stat scans per second", descriptorCount, scanTimer.Elapsed,
         1000*descriptorCount/scanTimer.ElapsedMilliseconds);
     return rootDescriptor;
 }