Force the last checkpoint to be saved.
am: 3a25dc2a39
Change-Id: I3616d56b0ef7bcc05235f2c4bc9a7d60ef0249f9
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index a0c7f57..80a423c 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -758,7 +758,7 @@
next_operation_num_++;
UpdateOverallProgress(false, "Completed ");
- CheckpointUpdateProgress();
+ CheckpointUpdateProgress(false);
}
// In major version 2, we don't add dummy operation to the payload.
@@ -787,7 +787,9 @@
// Since we extracted the SignatureMessage we need to advance the
// checkpoint, otherwise we would reload the signature and try to extract
// it again.
- CheckpointUpdateProgress();
+ // This is the last checkpoint for an update, force this checkpoint to be
+ // saved.
+ CheckpointUpdateProgress(true);
}
return true;
@@ -1782,10 +1784,14 @@
}
// Verifies the download size.
- TEST_AND_RETURN_VAL(ErrorCode::kPayloadSizeMismatchError,
- update_check_response_size ==
- metadata_size_ + metadata_signature_size_ +
- buffer_offset_);
+ if (update_check_response_size !=
+ metadata_size_ + metadata_signature_size_ + buffer_offset_) {
+ LOG(ERROR) << "update_check_response_size (" << update_check_response_size
+ << ") doesn't match metadata_size (" << metadata_size_
+ << ") + metadata_signature_size (" << metadata_signature_size_
+ << ") + buffer_offset (" << buffer_offset_ << ").";
+ return ErrorCode::kPayloadSizeMismatchError;
+ }
// Verifies the payload hash.
TEST_AND_RETURN_VAL(ErrorCode::kDownloadPayloadVerificationError,
@@ -1898,9 +1904,9 @@
return true;
}
-bool DeltaPerformer::CheckpointUpdateProgress() {
+bool DeltaPerformer::CheckpointUpdateProgress(bool force) {
base::Time curr_time = base::Time::Now();
- if (curr_time > update_checkpoint_time_) {
+ if (force || curr_time > update_checkpoint_time_) {
update_checkpoint_time_ = curr_time + update_checkpoint_wait_;
} else {
return false;
diff --git a/payload_consumer/delta_performer.h b/payload_consumer/delta_performer.h
index 36244dc..7f6fa9b 100644
--- a/payload_consumer/delta_performer.h
+++ b/payload_consumer/delta_performer.h
@@ -257,7 +257,8 @@
// Checkpoints the update progress into persistent storage to allow this
// update attempt to be resumed after reboot.
- bool CheckpointUpdateProgress();
+ // If |force| is false, checkpoint may be throttled.
+ bool CheckpointUpdateProgress(bool force);
// Primes the required update state. Returns true if the update state was
// successfully initialized to a saved resume state or if the update is a new