From c663b84573edee2c5ece78f4ee269be73ac3ca35 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 7 Oct 2016 19:20:47 +0200 Subject: [PATCH] Implement generic Store::queryValidPaths() --- src/libstore/binary-cache-store.hh | 3 --- src/libstore/store-api.cc | 11 +++++++++++ src/libstore/store-api.hh | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh index e369abe46..574696cf3 100644 --- a/src/libstore/binary-cache-store.hh +++ b/src/libstore/binary-cache-store.hh @@ -54,9 +54,6 @@ public: bool isValidPathUncached(const Path & path) override; - PathSet queryValidPaths(const PathSet & paths) override - { notImpl(); } - PathSet queryAllValidPaths() override { notImpl(); } diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 74014b47e..a830ae5bb 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -361,6 +361,17 @@ void Store::queryPathInfo(const Path & storePath, } +PathSet Store::queryValidPaths(const PathSet & paths) +{ + PathSet valid; + + for (auto & path : paths) + if (isValidPath(path)) valid.insert(path); + + return valid; +} + + /* Return a string accepted by decodeValidPathInfo() that registers the specified paths as valid. Note: it's the responsibility of the caller to provide a closure. */ diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index b876ffbba..ce1583b0c 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -306,7 +306,7 @@ protected: public: /* Query which of the given paths is valid. */ - virtual PathSet queryValidPaths(const PathSet & paths) = 0; + virtual PathSet queryValidPaths(const PathSet & paths); /* Query the set of all valid paths. Note that for some store backends, the name part of store paths may be omitted