forked from lix-project/lix
libstore: de-callback-ify Store::queryRealisation
Change-Id: I8d74745c519518f163f51dfaa39063836f17599e
This commit is contained in:
parent
17965bf11c
commit
28a98d152c
|
@ -716,34 +716,26 @@ ref<const ValidPathInfo> Store::queryPathInfo(const StorePath & storePath)
|
||||||
return ref<const ValidPathInfo>(info);
|
return ref<const ValidPathInfo>(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Store::queryRealisation(const DrvOutput & id,
|
std::shared_ptr<const Realisation> Store::queryRealisation(const DrvOutput & id)
|
||||||
Callback<std::shared_ptr<const Realisation>> callback) noexcept
|
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
|
||||||
if (diskCache) {
|
if (diskCache) {
|
||||||
auto [cacheOutcome, maybeCachedRealisation]
|
auto [cacheOutcome, maybeCachedRealisation]
|
||||||
= diskCache->lookupRealisation(getUri(), id);
|
= diskCache->lookupRealisation(getUri(), id);
|
||||||
switch (cacheOutcome) {
|
switch (cacheOutcome) {
|
||||||
case NarInfoDiskCache::oValid:
|
case NarInfoDiskCache::oValid:
|
||||||
debug("Returning a cached realisation for %s", id.to_string());
|
debug("Returning a cached realisation for %s", id.to_string());
|
||||||
callback(maybeCachedRealisation);
|
return maybeCachedRealisation;
|
||||||
return;
|
|
||||||
case NarInfoDiskCache::oInvalid:
|
case NarInfoDiskCache::oInvalid:
|
||||||
debug(
|
debug(
|
||||||
"Returning a cached missing realisation for %s",
|
"Returning a cached missing realisation for %s",
|
||||||
id.to_string());
|
id.to_string());
|
||||||
callback(nullptr);
|
return nullptr;
|
||||||
return;
|
|
||||||
case NarInfoDiskCache::oUnknown:
|
case NarInfoDiskCache::oUnknown:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (...) {
|
|
||||||
return callback.rethrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
auto info = queryRealisationUncached(id);
|
auto info = queryRealisationUncached(id);
|
||||||
|
|
||||||
if (diskCache) {
|
if (diskCache) {
|
||||||
|
@ -753,28 +745,7 @@ void Store::queryRealisation(const DrvOutput & id,
|
||||||
diskCache->upsertAbsentRealisation(getUri(), id);
|
diskCache->upsertAbsentRealisation(getUri(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(std::shared_ptr<const Realisation>(info));
|
return info;
|
||||||
|
|
||||||
} catch (...) {
|
|
||||||
callback.rethrow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<const Realisation> Store::queryRealisation(const DrvOutput & id)
|
|
||||||
{
|
|
||||||
using RealPtr = std::shared_ptr<const Realisation>;
|
|
||||||
std::promise<RealPtr> promise;
|
|
||||||
|
|
||||||
queryRealisation(id,
|
|
||||||
{[&](std::future<RealPtr> result) {
|
|
||||||
try {
|
|
||||||
promise.set_value(result.get());
|
|
||||||
} catch (...) {
|
|
||||||
promise.set_exception(std::current_exception());
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
|
|
||||||
return promise.get_future().get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Store::substitutePaths(const StorePathSet & paths)
|
void Store::substitutePaths(const StorePathSet & paths)
|
||||||
|
|
|
@ -371,12 +371,6 @@ public:
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<const Realisation> queryRealisation(const DrvOutput &);
|
std::shared_ptr<const Realisation> queryRealisation(const DrvOutput &);
|
||||||
|
|
||||||
/**
|
|
||||||
* Asynchronous version of queryRealisation().
|
|
||||||
*/
|
|
||||||
void queryRealisation(const DrvOutput &,
|
|
||||||
Callback<std::shared_ptr<const Realisation>> callback) noexcept;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given valid path info is sufficiently attested, by
|
* Check whether the given valid path info is sufficiently attested, by
|
||||||
|
|
Loading…
Reference in a new issue