aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/binary-cache-store.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-02 14:31:18 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-02 14:31:18 +0000
commit1b6461f671b5ad8475c6f30f82d8fc9422746508 (patch)
treeab3d3831ffe979f3673fd1071c59f33fb680933e /src/libstore/binary-cache-store.cc
parentefcd30da891eccdb3518e9c07afc6f907e9ac5e6 (diff)
parentbfa1acd85c4d15c5ea95337138f47672659e2a9e (diff)
Merge remote-tracking branch 'upstream/master' into validPathInfo-ca-proper-datatype
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 259ffaf59..583f9d8ac 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);