private FileHashInfo ComputeHash(FileHandle fileHandle, byte[] fileContents) { using (SHA256 sha256 = SHA256.Create()) { byte[] fileHash = sha256.ComputeHash(fileContents); FileHashInfo fileHashInfo = new FileHashInfo(fileHandle, fileHash); return(fileHashInfo); } }
public override async Task ExecuteAsync(HashFileByHandle payload, ITaskExecutionContext executionContext) { using (SHA256 sha256 = SHA256.Create()) { FileHandle fileHandle = ResolveFileHandle(payload.HandleId); byte[] fileContents = await ReadFileAsync(fileHandle); FileHashInfo fileHashInfo = ComputeHash(fileHandle, fileContents); StoreFileHashAndNotifyCompletion(fileHashInfo); } }
private void StoreFileHashAndNotifyCompletion(FileHashInfo fileHashInfo) { FileHashRepository.AddFileHash(fileHashInfo); ProcessingWatcher.NotifyFileHashed(fileHashInfo.FileHandle); }