Implement generic Store::queryValidPaths()

This commit is contained in:
Eelco Dolstra 2016-10-07 19:20:47 +02:00
parent 35db4f65a0
commit c663b84573
3 changed files with 12 additions and 4 deletions

View file

@ -54,9 +54,6 @@ public:
bool isValidPathUncached(const Path & path) override; bool isValidPathUncached(const Path & path) override;
PathSet queryValidPaths(const PathSet & paths) override
{ notImpl(); }
PathSet queryAllValidPaths() override PathSet queryAllValidPaths() override
{ notImpl(); } { notImpl(); }

View file

@ -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 /* Return a string accepted by decodeValidPathInfo() that
registers the specified paths as valid. Note: it's the registers the specified paths as valid. Note: it's the
responsibility of the caller to provide a closure. */ responsibility of the caller to provide a closure. */

View file

@ -306,7 +306,7 @@ protected:
public: public:
/* Query which of the given paths is valid. */ /* 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 /* Query the set of all valid paths. Note that for some store
backends, the name part of store paths may be omitted backends, the name part of store paths may be omitted