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/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index bb7c98c..d8e58b4 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -1959,7 +1959,10 @@
return true;
}
-bool DeltaPerformer::ResetUpdateProgress(PrefsInterface* prefs, bool quick) {
+bool DeltaPerformer::ResetUpdateProgress(
+ PrefsInterface* prefs,
+ bool quick,
+ bool skip_dynamic_partititon_metadata_updated) {
TEST_AND_RETURN_FALSE(prefs->SetInt64(kPrefsUpdateStateNextOperation,
kUpdateStateOperationInvalid));
if (!quick) {
@@ -1973,7 +1976,11 @@
prefs->SetInt64(kPrefsResumedUpdateFailures, 0);
prefs->Delete(kPrefsPostInstallSucceeded);
prefs->Delete(kPrefsVerityWritten);
- prefs->Delete(kPrefsDynamicPartitionMetadataUpdated);
+
+ if (!skip_dynamic_partititon_metadata_updated) {
+ LOG(INFO) << "Resetting recorded hash for prepared partitions.";
+ prefs->Delete(kPrefsDynamicPartitionMetadataUpdated);
+ }
}
return true;
}
diff --git a/payload_consumer/delta_performer.h b/payload_consumer/delta_performer.h
index 6dbd3b8..01fcc5c 100644
--- a/payload_consumer/delta_performer.h
+++ b/payload_consumer/delta_performer.h
@@ -143,9 +143,14 @@
// Resets the persistent update progress state to indicate that an update
// can't be resumed. Performs a quick update-in-progress reset if |quick| is
- // true, otherwise resets all progress-related update state. Returns true on
- // success, false otherwise.
- static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick);
+ // true, otherwise resets all progress-related update state.
+ // If |skip_dynamic_partititon_metadata_updated| is true, do not reset
+ // dynamic-partition-metadata-updated.
+ // Returns true on success, false otherwise.
+ static bool ResetUpdateProgress(
+ PrefsInterface* prefs,
+ bool quick,
+ bool skip_dynamic_partititon_metadata_updated = false);
// Attempts to parse the update metadata starting from the beginning of
// |payload|. On success, returns kMetadataParseSuccess. Returns