예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 private void StoreFileHashAndNotifyCompletion(FileHashInfo fileHashInfo)
 {
     FileHashRepository.AddFileHash(fileHashInfo);
     ProcessingWatcher.NotifyFileHashed(fileHashInfo.FileHandle);
 }