libstore: asyncify LogStore::getBuildLogExact
Change-Id: Ie8492c2a0dbdbaeebc0d1608ad461f3e7a7f5b52
This commit is contained in:
@@ -491,13 +491,16 @@ void BinaryCacheStore::addSignatures(const StorePath & storePath, const StringSe
|
||||
writeNarInfo(narInfo);
|
||||
}
|
||||
|
||||
std::optional<std::string> BinaryCacheStore::getBuildLogExact(const StorePath & path)
|
||||
{
|
||||
kj::Promise<Result<std::optional<std::string>>>
|
||||
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)
|
||||
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
|
||||
void addSignatures(const StorePath & storePath, const StringSet & sigs) override;
|
||||
|
||||
std::optional<std::string> getBuildLogExact(const StorePath & path) override;
|
||||
kj::Promise<Result<std::optional<std::string>>> getBuildLogExact(const StorePath & path) override;
|
||||
|
||||
void addBuildLog(const StorePath & drvPath, std::string_view log) override;
|
||||
|
||||
|
||||
@@ -1248,8 +1248,10 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor
|
||||
unknown, downloadSize, narSize);
|
||||
}
|
||||
|
||||
virtual std::optional<std::string> getBuildLogExact(const StorePath & path) override
|
||||
{ return std::nullopt; }
|
||||
virtual kj::Promise<Result<std::optional<std::string>>> getBuildLogExact(const StorePath & path) override
|
||||
{
|
||||
return {std::nullopt};
|
||||
}
|
||||
|
||||
virtual void addBuildLog(const StorePath & path, std::string_view log) override
|
||||
{ unsupported("addBuildLog"); }
|
||||
|
||||
@@ -82,8 +82,9 @@ box_ptr<Source> LocalFSStore::narFromPath(const StorePath & path)
|
||||
|
||||
const std::string LocalFSStore::drvsLogDir = "drvs";
|
||||
|
||||
std::optional<std::string> LocalFSStore::getBuildLogExact(const StorePath & path)
|
||||
{
|
||||
kj::Promise<Result<std::optional<std::string>>>
|
||||
LocalFSStore::getBuildLogExact(const StorePath & path)
|
||||
try {
|
||||
auto baseName = path.to_string();
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
@@ -95,17 +96,19 @@ std::optional<std::string> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
return getRealStoreDir() + "/" + std::string(storePath, config().storeDir.size() + 1);
|
||||
}
|
||||
|
||||
std::optional<std::string> getBuildLogExact(const StorePath & path) override;
|
||||
kj::Promise<Result<std::optional<std::string>>> getBuildLogExact(const StorePath & path) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ struct LogStore : public virtual Store
|
||||
*/
|
||||
kj::Promise<Result<std::optional<std::string>>> getBuildLog(const StorePath & path);
|
||||
|
||||
virtual std::optional<std::string> getBuildLogExact(const StorePath & path) = 0;
|
||||
virtual kj::Promise<Result<std::optional<std::string>>> getBuildLogExact(const StorePath & path) = 0;
|
||||
|
||||
virtual void addBuildLog(const StorePath & path, std::string_view log) = 0;
|
||||
|
||||
|
||||
@@ -59,8 +59,12 @@ public:
|
||||
}
|
||||
|
||||
// FIXME extend daemon protocol, move implementation to RemoteStore
|
||||
std::optional<std::string> getBuildLogExact(const StorePath & path) override
|
||||
{ unsupported("getBuildLogExact"); }
|
||||
kj::Promise<Result<std::optional<std::string>>> getBuildLogExact(const StorePath & path) override
|
||||
try {
|
||||
unsupported("getBuildLogExact");
|
||||
} catch (...) {
|
||||
return {result::current_exception()};
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user