aboutsummaryrefslogtreecommitdiff
path: root/src/nix/make-content-addressable.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/make-content-addressable.cc')
-rw-r--r--src/nix/make-content-addressable.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nix/make-content-addressable.cc b/src/nix/make-content-addressable.cc
index f9c7fef3f..0ebb8f13b 100644
--- a/src/nix/make-content-addressable.cc
+++ b/src/nix/make-content-addressable.cc
@@ -31,9 +31,12 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
},
};
}
+
+ Category category() override { return catUtility; }
+
void run(ref<Store> store, StorePaths storePaths) override
{
- auto paths = store->topoSortPaths(storePathsToSet(storePaths));
+ auto paths = store->topoSortPaths(StorePathSet(storePaths.begin(), storePaths.end()));
std::reverse(paths.begin(), paths.end());
@@ -45,7 +48,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
for (auto & path : paths) {
auto pathS = store->printStorePath(path);
auto oldInfo = store->queryPathInfo(path);
- auto oldHashPart = storePathToHash(pathS);
+ std::string oldHashPart(path.hashPart());
StringSink sink;
store->narFromPath(path, sink);
@@ -59,7 +62,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
hasSelfReference = true;
else {
auto i = remappings.find(ref);
- auto replacement = i != remappings.end() ? i->second.clone() : ref.clone();
+ 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));
@@ -74,18 +77,18 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
auto narHash = hashModuloSink.finish().first;
- ValidPathInfo info(store->makeFixedOutputPath(true, narHash, path.name(), references, hasSelfReference));
+ ValidPathInfo info(store->makeFixedOutputPath(FileIngestionMethod::Recursive, narHash, path.name(), references, hasSelfReference));
info.references = std::move(references);
- if (hasSelfReference) info.references.insert(info.path.clone());
+ if (hasSelfReference) info.references.insert(info.path);
info.narHash = narHash;
info.narSize = sink.s->size();
- info.ca = makeFixedOutputCA(true, info.narHash);
+ info.ca = makeFixedOutputCA(FileIngestionMethod::Recursive, info.narHash);
if (!json)
- printError("rewrote '%s' to '%s'", pathS, store->printStorePath(info.path));
+ printInfo("rewrote '%s' to '%s'", pathS, store->printStorePath(info.path));
auto source = sinkToSource([&](Sink & nextSink) {
- RewritingSink rsink2(oldHashPart, storePathToHash(store->printStorePath(info.path)), nextSink);
+ RewritingSink rsink2(oldHashPart, std::string(info.path.hashPart()), nextSink);
rsink2((unsigned char *) sink.s->data(), sink.s->size());
rsink2.flush();
});