Don't clear previous partitions in DeltaPerformer.
When we used to have a FilesystemVerifierAction before DownloadAction,
partitions in InstallPlan was filled in by FilesystemVerifierAction
with source hashes, but now that action is gone, DeltaPerformer is the
first action that touches partitions, so clearing partitions are not
needed. In multi payload case, partitions in previous payloads are
stored there so it should not be removed.
We could also move the partitions into Payload but that will make our
code more complex (keeping track of both payload index and partition
index in FilesystemVerifierAction and PostinstallRunnerAction) thus
more likely to have bugs.
This simple patch solves the same problem without polluting the code.
Bug: 36252799
Test: FilesystemVerifierAction verifies all partitions in all payloads.
Change-Id: I2aed02389bf047a6dedf59b306434ccea4eebca8
(cherry picked from commit cf6bd59a3cd149bd86d763e96ede81ce102d64d9)
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index b14a54f..84048eb 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -335,10 +335,14 @@
return false;
const PartitionUpdate& partition = partitions_[current_partition_];
+ size_t num_previous_partitions =
+ install_plan_->partitions.size() - partitions_.size();
+ const InstallPlan::Partition& install_part =
+ install_plan_->partitions[num_previous_partitions + current_partition_];
// Open source fds if we have a delta payload with minor version >= 2.
if (install_plan_->payload_type == InstallPayloadType::kDelta &&
GetMinorVersion() != kInPlaceMinorPayloadVersion) {
- source_path_ = install_plan_->partitions[current_partition_].source_path;
+ source_path_ = install_part.source_path;
int err;
source_fd_ = OpenFile(source_path_.c_str(), O_RDONLY, &err);
if (!source_fd_) {
@@ -350,7 +354,7 @@
}
}
- target_path_ = install_plan_->partitions[current_partition_].target_path;
+ target_path_ = install_part.target_path;
int err;
target_fd_ = OpenFile(target_path_.c_str(), O_RDWR, &err);
if (!target_fd_) {
@@ -366,8 +370,7 @@
<< "\"";
// Discard the end of the partition, but ignore failures.
- DiscardPartitionTail(
- target_fd_, install_plan_->partitions[current_partition_].target_size);
+ DiscardPartitionTail(target_fd_, install_part.target_size);
return true;
}
@@ -831,7 +834,6 @@
// Fill in the InstallPlan::partitions based on the partitions from the
// payload.
- install_plan_->partitions.clear();
for (const auto& partition : partitions_) {
InstallPlan::Partition install_part;
install_part.name = partition.partition_name();