aboutsummaryrefslogtreecommitdiff
path: root/src/nix/make-content-addressable.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-10-07 13:52:20 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-10-07 15:00:10 +0000
commitf8d562c0a7cef27c65d3cff96ad8ef384f05b331 (patch)
treeecba39f19746941564105f76e86cfa323a0bb019 /src/nix/make-content-addressable.cc
parentdae4409071b827a539acd0f46f91f15cfa1e1a7d (diff)
Use PathReferences more widely
Diffstat (limited to 'src/nix/make-content-addressable.cc')
-rw-r--r--src/nix/make-content-addressable.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/nix/make-content-addressable.cc b/src/nix/make-content-addressable.cc
index 7737f6d91..7695c98f8 100644
--- a/src/nix/make-content-addressable.cc
+++ b/src/nix/make-content-addressable.cc
@@ -55,19 +55,15 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
StringMap rewrites;
- StorePathSet references;
- bool hasSelfReference = false;
+ PathReferences<StorePath> refs;
+ refs.hasSelfReference = oldInfo->hasSelfReference;
for (auto & ref : oldInfo->references) {
- if (ref == path)
- hasSelfReference = true;
- else {
- auto i = remappings.find(ref);
- auto replacement = i != remappings.end() ? i->second : ref;
- // FIXME: warn about unremapped paths?
- if (replacement != ref)
- rewrites.insert_or_assign(store->printStorePath(ref), store->printStorePath(replacement));
- references.insert(std::move(replacement));
- }
+ auto i = remappings.find(ref);
+ auto replacement = i != remappings.end() ? i->second : ref;
+ // FIXME: warn about unremapped paths?
+ if (replacement != ref)
+ rewrites.insert_or_assign(store->printStorePath(ref), store->printStorePath(replacement));
+ refs.references.insert(std::move(replacement));
}
*sink.s = rewriteStrings(*sink.s, rewrites);
@@ -78,16 +74,20 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
auto narHash = hashModuloSink.finish().first;
ValidPathInfo info {
- store->makeFixedOutputPath(FileIngestionMethod::Recursive, narHash, path.name(), references, hasSelfReference),
+ *store,
+ StorePathDescriptor {
+ .name = std::string { path.name() },
+ .info = FixedOutputInfo {
+ {
+ .method = FileIngestionMethod::Recursive,
+ .hash = narHash,
+ },
+ std::move(refs),
+ },
+ },
narHash,
};
- info.references = std::move(references);
- info.hasSelfReference = std::move(hasSelfReference);
info.narSize = sink.s->size();
- info.ca = FixedOutputHash {
- .method = FileIngestionMethod::Recursive,
- .hash = info.narHash,
- };
if (!json)
printInfo("rewrote '%s' to '%s'", pathS, store->printStorePath(info.path));