DeltaPerformer: Don't destroy previously allocated space
After allocateSpaceForPayload() is called, applyPayload() with
the same hash should not destroy the allocated files then re-allocate.
Fix it so that DeltaPerformer::ResetUpdateProgress skip resetting
the hash in this case.
Bug: 138808058
Test: update_engine_client --allocate, then --apply
Change-Id: Ibc2a7449a6953a707d1c4f23ee11d572f498457c
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 3292dd5..034b4ea 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -217,7 +217,14 @@
install_plan_.is_resume = !payload_id.empty() &&
DeltaPerformer::CanResumeUpdate(prefs_, payload_id);
if (!install_plan_.is_resume) {
- if (!DeltaPerformer::ResetUpdateProgress(prefs_, false)) {
+ // No need to reset dynamic_partititon_metadata_updated. If previous calls
+ // to AllocateSpaceForPayload uses the same payload_id, reuse preallocated
+ // space. Otherwise, DeltaPerformer re-allocates space when the payload is
+ // applied.
+ if (!DeltaPerformer::ResetUpdateProgress(
+ prefs_,
+ false /* quick */,
+ true /* skip_dynamic_partititon_metadata_updated */)) {
LOG(WARNING) << "Unable to reset the update progress.";
}
if (!prefs_->SetString(kPrefsUpdateCheckResponseHash, payload_id)) {