#include "local-overlay-store.hh" #include "callback.hh" 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()) { } 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); } void LocalOverlayStore::queryPathInfoUncached(const StorePath & path, Callback> callback) noexcept { auto callbackPtr = std::make_shared(std::move(callback)); LocalStore::queryPathInfoUncached(path, {[this, path, callbackPtr](std::future> fut) { try { auto info = fut.get(); if (info) return (*callbackPtr)(std::move(info)); } catch (...) { return callbackPtr->rethrow(); } // If we don't have it, check lower store lowerStore->queryPathInfo(path, {[path, callbackPtr](std::future> fut) { try { (*callbackPtr)(fut.get().get_ptr()); } catch (...) { return callbackPtr->rethrow(); } }}); }}); } static RegisterStoreImplementation regLocalOverlayStore; }