Specialize LocalOverlayStore::queryPathInfoUncached

This commit is contained in:
John Ericson 2023-05-08 17:30:17 -04:00
parent 31e98ed0a0
commit 5406256d78
2 changed files with 29 additions and 0 deletions

View file

@ -1,4 +1,5 @@
#include "local-overlay-store.hh"
#include "callback.hh"
namespace nix {
@ -26,6 +27,31 @@ void LocalOverlayStore::registerDrvOutput(const Realisation & info)
}
void LocalOverlayStore::queryPathInfoUncached(const StorePath & path,
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
{
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
// If we don't have it, check lower store
LocalStore::queryPathInfoUncached(path,
{[this, path, callbackPtr](std::future<std::shared_ptr<const ValidPathInfo>> fut) {
try {
(*callbackPtr)(fut.get());
} catch (...) {
lowerStore->queryPathInfo(path,
{[path, callbackPtr](std::future<ref<const ValidPathInfo>> fut) {
try {
(*callbackPtr)(fut.get().get_ptr());
} catch (...) {
callbackPtr->rethrow();
}
}});
}
}});
}
static RegisterStoreImplementation<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore;
}

View file

@ -71,6 +71,9 @@ private:
// Overridden methods…
void registerDrvOutput(const Realisation & info) override;
void queryPathInfoUncached(const StorePath & path,
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept override;
};
}