checkpoint: Fix metadata file contents bug In aosp/787759, Checkpoint changed the way kMetadataCPFile stored the retry count, but didn't account for "-1" as a special case. As a result, Checkpoint no longer reported `needsRollback` to be true when `startCheckpoint(-1)` was called. Bug: none Test: presubmits (lmk if there's something better) Change-Id: I4acb929eb3471409b986f74493993a9f1d84e4a5
diff --git a/Checkpoint.cpp b/Checkpoint.cpp index 76e46fb..195a137 100644 --- a/Checkpoint.cpp +++ b/Checkpoint.cpp
@@ -136,13 +136,16 @@ return error(ENOTSUP, "Checkpoints not supported"); if (retry < -1) return error(EINVAL, "Retry count must be more than -1"); - std::string content = std::to_string(retry + 1); + std::string content; if (retry == -1) { + content = std::to_string(-1); auto module = BootControlClient::WaitForService(); if (module) { std::string suffix = module->GetSuffix(module->GetCurrentSlot()); if (!suffix.empty()) content += " " + suffix; } + } else { + content = std::to_string(retry + 1); } if (!android::base::WriteStringToFile(content, kMetadataCPFile)) return error("Failed to write checkpoint file");