Skip to content

Commit

Permalink
Verify added path matches calculated store path in add-to-store
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbauer committed Jun 2, 2020
1 parent 7432a9d commit 24544d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/nix/add-to-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ struct CmdAddToStore : MixDryRun, StoreCommand
info.narSize = sink.s->size();
info.ca = makeFixedOutputCA(ingestionMethod, hash);

if (!dryRun)
store->addToStore(*namePart, path, ingestionMethod, git ? htSHA1 : htSHA256);
if (!dryRun) {
auto addedPath = store->addToStore(*namePart, path, ingestionMethod, git ? htSHA1 : htSHA256);
if (addedPath != info.path)
throw Error(format("Added path %s does not match calculated path %s; something has changed") % addedPath.to_string() % info.path.to_string());
}

logger->stdout("%s", store->printStorePath(info.path));
}
Expand Down

0 comments on commit 24544d3

Please sign in to comment.