diff --git a/lix/libstore/binary-cache-store.cc b/lix/libstore/binary-cache-store.cc index d956ac4c2..39a3902f6 100644 --- a/lix/libstore/binary-cache-store.cc +++ b/lix/libstore/binary-cache-store.cc @@ -491,13 +491,16 @@ void BinaryCacheStore::addSignatures(const StorePath & storePath, const StringSe writeNarInfo(narInfo); } -std::optional BinaryCacheStore::getBuildLogExact(const StorePath & path) -{ +kj::Promise>> +BinaryCacheStore::getBuildLogExact(const StorePath & path) +try { auto logPath = "log/" + std::string(baseNameOf(printStorePath(path))); debug("fetching build log from binary cache '%s/%s'", getUri(), logPath); - return getFileContents(logPath); + co_return getFileContents(logPath); +} catch (...) { + co_return result::current_exception(); } void BinaryCacheStore::addBuildLog(const StorePath & drvPath, std::string_view log) diff --git a/lix/libstore/binary-cache-store.hh b/lix/libstore/binary-cache-store.hh index 9d921d3b9..09fbdf49a 100644 --- a/lix/libstore/binary-cache-store.hh +++ b/lix/libstore/binary-cache-store.hh @@ -144,7 +144,7 @@ public: void addSignatures(const StorePath & storePath, const StringSet & sigs) override; - std::optional getBuildLogExact(const StorePath & path) override; + kj::Promise>> getBuildLogExact(const StorePath & path) override; void addBuildLog(const StorePath & drvPath, std::string_view log) override; diff --git a/lix/libstore/build/local-derivation-goal.cc b/lix/libstore/build/local-derivation-goal.cc index a9a4437b7..bc3ce82a6 100644 --- a/lix/libstore/build/local-derivation-goal.cc +++ b/lix/libstore/build/local-derivation-goal.cc @@ -1248,8 +1248,10 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor unknown, downloadSize, narSize); } - virtual std::optional getBuildLogExact(const StorePath & path) override - { return std::nullopt; } + virtual kj::Promise>> getBuildLogExact(const StorePath & path) override + { + return {std::nullopt}; + } virtual void addBuildLog(const StorePath & path, std::string_view log) override { unsupported("addBuildLog"); } diff --git a/lix/libstore/local-fs-store.cc b/lix/libstore/local-fs-store.cc index c385bbf3d..9428a3cbc 100644 --- a/lix/libstore/local-fs-store.cc +++ b/lix/libstore/local-fs-store.cc @@ -82,8 +82,9 @@ box_ptr LocalFSStore::narFromPath(const StorePath & path) const std::string LocalFSStore::drvsLogDir = "drvs"; -std::optional LocalFSStore::getBuildLogExact(const StorePath & path) -{ +kj::Promise>> +LocalFSStore::getBuildLogExact(const StorePath & path) +try { auto baseName = path.to_string(); for (int j = 0; j < 2; j++) { @@ -95,17 +96,19 @@ std::optional LocalFSStore::getBuildLogExact(const StorePath & path Path logBz2Path = logPath + ".bz2"; if (pathExists(logPath)) - return readFile(logPath); + co_return readFile(logPath); else if (pathExists(logBz2Path)) { try { - return decompress("bzip2", readFile(logBz2Path)); + co_return decompress("bzip2", readFile(logBz2Path)); } catch (Error &) { } } } - return std::nullopt; + co_return std::nullopt; +} catch (...) { + co_return result::current_exception(); } } diff --git a/lix/libstore/local-fs-store.hh b/lix/libstore/local-fs-store.hh index d31264b47..d469f8011 100644 --- a/lix/libstore/local-fs-store.hh +++ b/lix/libstore/local-fs-store.hh @@ -70,7 +70,7 @@ public: return getRealStoreDir() + "/" + std::string(storePath, config().storeDir.size() + 1); } - std::optional getBuildLogExact(const StorePath & path) override; + kj::Promise>> getBuildLogExact(const StorePath & path) override; }; diff --git a/lix/libstore/log-store.cc b/lix/libstore/log-store.cc index eeb07d737..aeab88cbb 100644 --- a/lix/libstore/log-store.cc +++ b/lix/libstore/log-store.cc @@ -7,7 +7,7 @@ try { auto maybePath = TRY_AWAIT(getBuildDerivationPath(path)); if (!maybePath) co_return std::nullopt; - co_return getBuildLogExact(maybePath.value()); + co_return TRY_AWAIT(getBuildLogExact(maybePath.value())); } catch (...) { co_return result::current_exception(); } diff --git a/lix/libstore/log-store.hh b/lix/libstore/log-store.hh index 68e5f1964..04f38fcea 100644 --- a/lix/libstore/log-store.hh +++ b/lix/libstore/log-store.hh @@ -16,7 +16,7 @@ struct LogStore : public virtual Store */ kj::Promise>> getBuildLog(const StorePath & path); - virtual std::optional getBuildLogExact(const StorePath & path) = 0; + virtual kj::Promise>> getBuildLogExact(const StorePath & path) = 0; virtual void addBuildLog(const StorePath & path, std::string_view log) = 0; diff --git a/lix/libstore/ssh-store.cc b/lix/libstore/ssh-store.cc index 8e2224d9a..757230d86 100644 --- a/lix/libstore/ssh-store.cc +++ b/lix/libstore/ssh-store.cc @@ -59,8 +59,12 @@ public: } // FIXME extend daemon protocol, move implementation to RemoteStore - std::optional getBuildLogExact(const StorePath & path) override - { unsupported("getBuildLogExact"); } + kj::Promise>> getBuildLogExact(const StorePath & path) override + try { + unsupported("getBuildLogExact"); + } catch (...) { + return {result::current_exception()}; + } protected: