Refactor ECC related code to a separate class
Both PartitionWriter and VABC partition writer need to deal with
hashes/ecc. Refactor out common code to a free function.
Test: th
Change-Id: I40033a1671a2c3a63e7d2d8266c4a0087d067100
diff --git a/payload_consumer/vabc_partition_writer.cc b/payload_consumer/vabc_partition_writer.cc
index 0843fff..a27847c 100644
--- a/payload_consumer/vabc_partition_writer.cc
+++ b/payload_consumer/vabc_partition_writer.cc
@@ -90,7 +90,15 @@
auto converted = ConvertToCowOperations(partition_update_.operations(),
partition_update_.merge_operations());
- WriteAllCowOps(block_size_, converted, cow_writer_.get(), source_fd_);
+ if (!converted.empty()) {
+ // Use source fd directly. Ideally we want to verify all extents used in
+ // source copy, but then what do we do if some extents contain correct
+ // hashes and some don't?
+ auto source_fd = std::make_shared<EintrSafeFileDescriptor>();
+ TEST_AND_RETURN_FALSE_ERRNO(
+ source_fd->Open(install_part_.source_path.c_str(), O_RDONLY));
+ WriteAllCowOps(block_size_, converted, cow_writer_.get(), source_fd);
+ }
return true;
}