diff options
author | Amin Hassani <ahassani@google.com> | 2017-12-06 15:31:17 -0800 |
---|---|---|
committer | Amin Hassani <ahassani@google.com> | 2018-02-05 12:53:18 -0800 |
commit | b379d19c05c5128a7fa45b72dbe74a764d143b98 (patch) | |
tree | 4401a36d4174b68dfeff004d85f4ff3a1f45e5da /payload_consumer/file_descriptor_utils.h | |
parent | 4e13cf4743d5c02dec7030c71a3c7e2fa8da7aa8 (diff) |
Restructure hash calculation in delta_performer
This patch moves DeltaPerformer::CalculateAndValidateHash to
fd_utils::ReadAndHashExtents and cleans up the code. It also adds
unittests for ReadAndHashExtents.
Bug: None
Test: unittest pass
Change-Id: I297cf79ef38a7495d5bcc0e6516a1ca783e505ea
Signed-off-by: Amin Hassani <ahassani@google.com>
Diffstat (limited to 'payload_consumer/file_descriptor_utils.h')
-rw-r--r-- | payload_consumer/file_descriptor_utils.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/payload_consumer/file_descriptor_utils.h b/payload_consumer/file_descriptor_utils.h index d1289d6c..397c35e5 100644 --- a/payload_consumer/file_descriptor_utils.h +++ b/payload_consumer/file_descriptor_utils.h @@ -39,7 +39,17 @@ bool CopyAndHashExtents( const google::protobuf::RepeatedPtrField<Extent>& src_extents, FileDescriptorPtr target, const google::protobuf::RepeatedPtrField<Extent>& tgt_extents, - uint32_t block_size, + uint64_t block_size, + brillo::Blob* hash_out); + +// Reads blocks from |source| and caculates the hash. The blocks to read are +// specified by |extents|. Stores the hash in |hash_out| if it is not null. The +// block sizes are passed as |block_size|. In case of error reading, it returns +// false and the value pointed by |hash_out| is undefined. +bool ReadAndHashExtents( + FileDescriptorPtr source, + const google::protobuf::RepeatedPtrField<Extent>& extents, + uint64_t block_size, brillo::Blob* hash_out); } // namespace fd_utils |