aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/binary-cache-store.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r--src/libstore/binary-cache-store.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index 2d92e1c50..a73b3e8c5 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -86,8 +86,7 @@ void BinaryCacheStore::getFile(const std::string & path, Sink & sink)
promise.set_exception(std::current_exception());
}
}});
- auto data = promise.get_future().get();
- sink((unsigned char *) data->data(), data->size());
+ sink(*promise.get_future().get());
}
std::shared_ptr<std::string> BinaryCacheStore::getFile(const std::string & path)
@@ -449,7 +448,9 @@ StorePath BinaryCacheStore::addTextToStore(const string & name, const string & s
if (!repair && isValidPath(path))
return path;
- auto source = StringSource { s };
+ StringSink sink;
+ dumpString(s, sink);
+ auto source = StringSource { *sink.s };
return addToStoreCommon(source, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
*this,
@@ -468,6 +469,24 @@ StorePath BinaryCacheStore::addTextToStore(const string & name, const string & s
})->path;
}
+std::optional<const Realisation> BinaryCacheStore::queryRealisation(const DrvOutput & id)
+{
+ auto outputInfoFilePath = realisationsPrefix + "/" + id.to_string() + ".doi";
+ auto rawOutputInfo = getFile(outputInfoFilePath);
+
+ if (rawOutputInfo) {
+ return {Realisation::fromJSON(
+ nlohmann::json::parse(*rawOutputInfo), outputInfoFilePath)};
+ } else {
+ return std::nullopt;
+ }
+}
+
+void BinaryCacheStore::registerDrvOutput(const Realisation& info) {
+ auto filePath = realisationsPrefix + "/" + info.id.to_string() + ".doi";
+ upsertFile(filePath, info.toJSON().dump(), "application/json");
+}
+
ref<FSAccessor> BinaryCacheStore::getFSAccessor()
{
return make_ref<RemoteFSAccessor>(ref<Store>(shared_from_this()), localNarCache);