diff --git a/src/libstore/include/nix/store/legacy-ssh-store.hh b/src/libstore/include/nix/store/legacy-ssh-store.hh index 994918f90f0..8b18176b10e 100644 --- a/src/libstore/include/nix/store/legacy-ssh-store.hh +++ b/src/libstore/include/nix/store/legacy-ssh-store.hh @@ -214,6 +214,12 @@ public: { unsupported("queryRealisation"); } + + StorePathSet querySubstitutablePaths(const StorePathSet & paths) override + { + // not supported + return {}; + } }; } // namespace nix diff --git a/src/libstore/include/nix/store/local-store.hh b/src/libstore/include/nix/store/local-store.hh index b5de22095b8..adbf2b26efe 100644 --- a/src/libstore/include/nix/store/local-store.hh +++ b/src/libstore/include/nix/store/local-store.hh @@ -232,8 +232,6 @@ public: std::optional queryPathFromHashPart(const std::string & hashPart) override; - StorePathSet querySubstitutablePaths(const StorePathSet & paths) override; - bool pathInfoIsUntrusted(const ValidPathInfo &) override; bool realisationIsUntrusted(const Realisation &) override; diff --git a/src/libstore/include/nix/store/store-api.hh b/src/libstore/include/nix/store/store-api.hh index 3261a553e21..c4c9bc93051 100644 --- a/src/libstore/include/nix/store/store-api.hh +++ b/src/libstore/include/nix/store/store-api.hh @@ -497,10 +497,7 @@ public: /** * Query which of the given paths have substitutes. */ - virtual StorePathSet querySubstitutablePaths(const StorePathSet & paths) - { - return {}; - }; + virtual StorePathSet querySubstitutablePaths(const StorePathSet & paths); /** * Query substitute info (i.e. references, derivers and download diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 70ce6b4f28b..4b92d752291 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -867,40 +867,6 @@ std::optional LocalStore::queryPathFromHashPart(const std::string & h }); } -StorePathSet LocalStore::querySubstitutablePaths(const StorePathSet & paths) -{ - if (!settings.useSubstitutes) - return StorePathSet(); - - StorePathSet remaining; - for (auto & i : paths) - remaining.insert(i); - - StorePathSet res; - - for (auto & sub : getDefaultSubstituters()) { - if (remaining.empty()) - break; - if (sub->storeDir != storeDir) - continue; - if (!sub->config.wantMassQuery) - continue; - - auto valid = sub->queryValidPaths(remaining); - - StorePathSet remaining2; - for (auto & path : remaining) - if (valid.count(path)) - res.insert(path); - else - remaining2.insert(path); - - std::swap(remaining, remaining2); - } - - return res; -} - void LocalStore::registerValidPath(const ValidPathInfo & info) { registerValidPaths({{info.path, info}}); diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index fc05667157e..647787df224 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -471,6 +471,40 @@ void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, Substituta } } +StorePathSet Store::querySubstitutablePaths(const StorePathSet & paths) +{ + if (!settings.useSubstitutes) + return StorePathSet(); + + StorePathSet remaining; + for (auto & i : paths) + remaining.insert(i); + + StorePathSet res; + + for (auto & sub : getDefaultSubstituters()) { + if (remaining.empty()) + break; + if (sub->storeDir != storeDir) + continue; + if (!sub->config.wantMassQuery) + continue; + + auto valid = sub->queryValidPaths(remaining); + + StorePathSet remaining2; + for (auto & path : remaining) + if (valid.count(path)) + res.insert(path); + else + remaining2.insert(path); + + std::swap(remaining, remaining2); + } + + return res; +} + bool Store::isValidPath(const StorePath & storePath) { auto res = pathInfoCache->lock()->get(storePath);