aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/binary-cache-store.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-05-29 16:19:48 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-05-29 17:02:32 -0400
commitfac0c2d54a6b04175b40009506f2720d2594ed4e (patch)
treeef6ef3e0fee28a0a300e7e1197da1a5596c5a341 /src/libstore/binary-cache-store.cc
parentf60ce4fa207a210e23a1142d3a8ead611526e6e1 (diff)
Remove addToStore variant as requested by `FIXME`
The idea is it's always more flexible to consumer a `Source` than a plain string, and it might even reduce memory consumption. I also looked at `addToStoreFromDump` with its `// FIXME: remove?`, but the worked needed for that is far more up for interpretation, so I punted for now.
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r--src/libstore/binary-cache-store.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index f13736c58..357962007 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -113,9 +113,12 @@ void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
diskCache->upsertNarInfo(getUri(), hashPart, std::shared_ptr<NarInfo>(narInfo));
}
-void BinaryCacheStore::addToStore(const ValidPathInfo & info, const ref<std::string> & nar,
+void BinaryCacheStore::addToStore(const ValidPathInfo & info, Source & narSource,
RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr<FSAccessor> accessor)
{
+ // FIXME: See if we can use the original source to reduce memory usage.
+ auto nar = make_ref<std::string>(narSource.drain());
+
if (!repair && isValidPath(info.path)) return;
/* Verify that all references are valid. This may do some .narinfo
@@ -347,7 +350,8 @@ StorePath BinaryCacheStore::addToStore(const string & name, const Path & srcPath
ValidPathInfo info(makeFixedOutputPath(method, h, name));
- addToStore(info, sink.s, repair, CheckSigs, nullptr);
+ auto source = StringSource { *sink.s };
+ addToStore(info, source, repair, CheckSigs, nullptr);
return std::move(info.path);
}
@@ -361,7 +365,8 @@ StorePath BinaryCacheStore::addTextToStore(const string & name, const string & s
if (repair || !isValidPath(info.path)) {
StringSink sink;
dumpString(s, sink);
- addToStore(info, sink.s, repair, CheckSigs, nullptr);
+ auto source = StringSource { *sink.s };
+ addToStore(info, source, repair, CheckSigs, nullptr);
}
return std::move(info.path);