From 5b243a2b4bf88f41c87569773af84671ba83e890 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 18 Jan 2022 16:14:01 +0100 Subject: [PATCH] BinaryCacheStore: Implement addBuildLog() --- src/libstore/binary-cache-store.cc | 10 ++++++++++ src/libstore/binary-cache-store.hh | 3 +++ src/libstore/local-binary-cache-store.cc | 1 + 3 files changed, 14 insertions(+) diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 7d25e2160..6e4458f7a 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -512,4 +512,14 @@ std::optional BinaryCacheStore::getBuildLog(const StorePath & path) return getFile(logPath); } +void BinaryCacheStore::addBuildLog(const StorePath & drvPath, std::string_view log) +{ + assert(drvPath.isDerivation()); + + upsertFile( + "log/" + std::string(drvPath.to_string()), + (std::string) log, // FIXME: don't copy + "text/plain; charset=utf-8"); +} + } diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh index 46ff67c77..7599230d9 100644 --- a/src/libstore/binary-cache-store.hh +++ b/src/libstore/binary-cache-store.hh @@ -51,6 +51,7 @@ public: const std::string & mimeType) = 0; void upsertFile(const std::string & path, + // FIXME: use std::string_view std::string && data, const std::string & mimeType); @@ -120,6 +121,8 @@ public: std::optional getBuildLog(const StorePath & path) override; + void addBuildLog(const StorePath & drvPath, std::string_view log) override; + }; MakeError(NoSuchBinaryCacheFile, Error); diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc index f93111fce..f754770f9 100644 --- a/src/libstore/local-binary-cache-store.cc +++ b/src/libstore/local-binary-cache-store.cc @@ -96,6 +96,7 @@ void LocalBinaryCacheStore::init() createDirs(binaryCacheDir + "/" + realisationsPrefix); if (writeDebugInfo) createDirs(binaryCacheDir + "/debuginfo"); + createDirs(binaryCacheDir + "/log"); BinaryCacheStore::init(); }