summaryrefslogtreecommitdiff
path: root/payload_consumer/file_descriptor_utils.cc
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2021-02-09 14:06:25 -0500
committerTreehugger Robot <treehugger-gerrit@google.com>2021-04-20 06:08:38 +0000
commit4d22ca2ab60f99f25d613f1ede3e1f16d9cc76cf (patch)
treebc2c54262cc3d4a777a667fe3089c00cafbf6fd8 /payload_consumer/file_descriptor_utils.cc
parent0c71550bf36a8d1590486e480fe2deb7253664cb (diff)
Refactor extent writer to take filedescriptor in constructor
Functions which receive an instance of extent writer need to manually pass fd to ExtentWriter via Init() call, which breaks separation of concerns. It makes it hard for us to decouple InstallOp execution from writing of data, as the execution unit must be aware of which fd to pass to extent writer. In addition, many extents writer, such as snapshot extent writer, simply ignores the fd parameter, which is a indication of poor code structure. To address the above issue, we pass FileDescriptorPtr via constructor if needed. This way, whoever is "executing" InstallOps don't need to care about where the output data is going, and whoever's writing the data would be responsible for initializing an ExtentWriter. Test: th Change-Id: I6d1eabde085eefd55da9ecc0352d4a16ae458698
Diffstat (limited to 'payload_consumer/file_descriptor_utils.cc')
-rw-r--r--payload_consumer/file_descriptor_utils.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/payload_consumer/file_descriptor_utils.cc b/payload_consumer/file_descriptor_utils.cc
index 846cbd72..9a6a601e 100644
--- a/payload_consumer/file_descriptor_utils.cc
+++ b/payload_consumer/file_descriptor_utils.cc
@@ -82,8 +82,8 @@ bool CopyAndHashExtents(FileDescriptorPtr source,
const RepeatedPtrField<Extent>& tgt_extents,
uint64_t block_size,
brillo::Blob* hash_out) {
- DirectExtentWriter writer;
- TEST_AND_RETURN_FALSE(writer.Init(target, tgt_extents, block_size));
+ DirectExtentWriter writer{target};
+ TEST_AND_RETURN_FALSE(writer.Init(tgt_extents, block_size));
TEST_AND_RETURN_FALSE(utils::BlocksInExtents(src_extents) ==
utils::BlocksInExtents(tgt_extents));
TEST_AND_RETURN_FALSE(