Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Fix aktualizr-repo --emptytargets.
Browse files Browse the repository at this point in the history
It did not match the format of empty targets that the server actually
sends us.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
  • Loading branch information
pattivacek committed Apr 15, 2019
1 parent 9c5ef10 commit b67da89
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/aktualizr_repo/director_repo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ void DirectorRepo::signTargets() {
boost::filesystem::remove(path_ / "repo/director/staging/targets.json");
updateRepo();
}

void DirectorRepo::emptyTargets() {
const boost::filesystem::path current = path_ / "repo/director/targets.json";
const boost::filesystem::path staging = path_ / "repo/director/staging/targets.json";

Json::Value targets_current = Utils::parseJSONFile(current);
Json::Value targets_unsigned;
targets_unsigned = Utils::parseJSONFile(staging);
targets_unsigned["targets"].clear();
targets_unsigned["_type"] = "Targets";
targets_unsigned["expires"] = expiration_time_;
targets_unsigned["version"] = (targets_current["signed"]["version"].asUInt()) + 1;
targets_unsigned["targets"] = Json::objectValue;
if (repo_type_ == Uptane::RepositoryType::Director() && correlation_id_ != "") {
targets_unsigned["custom"]["correlationId"] = correlation_id_;
}
Utils::writeFile(staging, Utils::jsonToCanonicalStr(targets_unsigned));
}

Expand All @@ -75,4 +85,4 @@ void DirectorRepo::oldTargets() {
Json::Value targets_current = Utils::parseJSONFile(current);
Json::Value targets_unsigned = targets_current["signed"];
Utils::writeFile(staging, Utils::jsonToCanonicalStr(targets_unsigned));
}
}

0 comments on commit b67da89

Please sign in to comment.