2023-05-08 17:20:06 +03:00
|
|
|
#include "local-overlay-store.hh"
|
2023-05-09 00:30:17 +03:00
|
|
|
#include "callback.hh"
|
2023-05-08 17:20:06 +03:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
LocalOverlayStore::LocalOverlayStore(const Params & params)
|
|
|
|
: StoreConfig(params)
|
|
|
|
, LocalFSStoreConfig(params)
|
|
|
|
, LocalStoreConfig(params)
|
|
|
|
, LocalOverlayStoreConfig(params)
|
|
|
|
, Store(params)
|
|
|
|
, LocalFSStore(params)
|
|
|
|
, LocalStore(params)
|
|
|
|
, lowerStore(openStore(lowerStoreUri).dynamic_pointer_cast<LocalFSStore>())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-08 23:48:55 +03:00
|
|
|
void LocalOverlayStore::registerDrvOutput(const Realisation & info)
|
|
|
|
{
|
|
|
|
// First do queryRealisation on lower layer to populate DB
|
|
|
|
auto res = lowerStore->queryRealisation(info.id);
|
|
|
|
if (res)
|
|
|
|
LocalStore::registerDrvOutput(*res);
|
|
|
|
|
|
|
|
LocalStore::registerDrvOutput(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-09 00:30:17 +03:00
|
|
|
void LocalOverlayStore::queryPathInfoUncached(const StorePath & path,
|
|
|
|
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
|
|
|
{
|
|
|
|
|
|
|
|
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
|
|
|
|
|
|
|
|
LocalStore::queryPathInfoUncached(path,
|
|
|
|
{[this, path, callbackPtr](std::future<std::shared_ptr<const ValidPathInfo>> fut) {
|
|
|
|
try {
|
2023-05-09 00:37:40 +03:00
|
|
|
auto info = fut.get();
|
|
|
|
if (info)
|
|
|
|
return (*callbackPtr)(std::move(info));
|
2023-05-09 00:30:17 +03:00
|
|
|
} catch (...) {
|
2023-05-09 00:37:40 +03:00
|
|
|
return callbackPtr->rethrow();
|
2023-05-09 00:30:17 +03:00
|
|
|
}
|
2023-05-09 00:37:40 +03:00
|
|
|
// If we don't have it, check lower store
|
|
|
|
lowerStore->queryPathInfo(path,
|
|
|
|
{[path, callbackPtr](std::future<ref<const ValidPathInfo>> fut) {
|
|
|
|
try {
|
|
|
|
(*callbackPtr)(fut.get().get_ptr());
|
|
|
|
} catch (...) {
|
|
|
|
return callbackPtr->rethrow();
|
|
|
|
}
|
|
|
|
}});
|
2023-05-09 00:30:17 +03:00
|
|
|
}});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-08 17:20:06 +03:00
|
|
|
static RegisterStoreImplementation<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore;
|
|
|
|
|
|
|
|
}
|