From 5406256d78244cf838eb917c35895035cbe1e402 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 8 May 2023 17:30:17 -0400 Subject: [PATCH] Specialize `LocalOverlayStore::queryPathInfoUncached` --- src/libstore/local-overlay-store.cc | 26 ++++++++++++++++++++++++++ src/libstore/local-overlay-store.hh | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/libstore/local-overlay-store.cc b/src/libstore/local-overlay-store.cc index 2e3564df9..545e8d28f 100644 --- a/src/libstore/local-overlay-store.cc +++ b/src/libstore/local-overlay-store.cc @@ -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> callback) noexcept +{ + + auto callbackPtr = std::make_shared(std::move(callback)); + + // If we don't have it, check lower store + LocalStore::queryPathInfoUncached(path, + {[this, path, callbackPtr](std::future> fut) { + try { + (*callbackPtr)(fut.get()); + } catch (...) { + lowerStore->queryPathInfo(path, + {[path, callbackPtr](std::future> fut) { + try { + (*callbackPtr)(fut.get().get_ptr()); + } catch (...) { + callbackPtr->rethrow(); + } + }}); + } + }}); +} + + static RegisterStoreImplementation regLocalOverlayStore; } diff --git a/src/libstore/local-overlay-store.hh b/src/libstore/local-overlay-store.hh index e5329f5d9..12b705efb 100644 --- a/src/libstore/local-overlay-store.hh +++ b/src/libstore/local-overlay-store.hh @@ -71,6 +71,9 @@ private: // Overridden methods… void registerDrvOutput(const Realisation & info) override; + + void queryPathInfoUncached(const StorePath & path, + Callback> callback) noexcept override; }; }