void LoadBinaryHashes(IVideothequeLoadingUI ui) { ui.StartPOSTWork("Indexing videofiles in " + RawFolder.FullName); var hashes = new RawFileHashes <DirectoryInfo>(); ComputeHashesInRawSubdirectories(RawFolder, Names.FaceFileName, Names.HashFileName, false, hashes); if (hashes.DuplicatedHashes.Count != 0) { var message = "Some input video files are duplicated. This is not acceptable. Please resolve the issue. The duplications are:\r\n"; foreach (var e in hashes.DuplicatedHashes) { message += e.Value.Select(z => z.FullName).Select(z => MyPath.RelativeTo(z, RawFolder.FullName)).Aggregate((a, b) => a + ", " + b) + "\r\n"; } ui.Request(message, new VideothequeLoadingRequestItem[0]); throw new LoadingException(); } binaryHashes = hashes.Hashes; ui.CompletePOSTWork(true); }
public static void ComputeHashesInRawSubdirectories(DirectoryInfo directory, string targetFileName, string hashFileName, bool recomputeAll, RawFileHashes <DirectoryInfo> hashes) { var files = directory.GetFiles(); if (files.Any(z => z.Name == targetFileName)) { string hash = ComputeHash(directory, targetFileName, hashFileName, recomputeAll); hashes.Add(hash, directory); } else { foreach (var d in directory.GetDirectories()) { ComputeHashesInRawSubdirectories(d, targetFileName, hashFileName, recomputeAll, hashes); } } }