1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 22:12:43 +01:00

Specialize more methods, fix tests

This commit is contained in:
John Ericson 2023-05-09 10:22:38 -04:00
parent b3d320c594
commit ddaf2750b5
4 changed files with 41 additions and 19 deletions

View file

@ -4,9 +4,7 @@
namespace nix {
Path LocalOverlayStoreConfig::toUpperPath(const StorePath & path) {
auto res = upperLayer + "/" + path.to_string();
warn("upper path: %s", res);
return res;
return upperLayer + "/" + path.to_string();
}
LocalOverlayStore::LocalOverlayStore(const Params & params)
@ -91,7 +89,31 @@ bool LocalOverlayStore::isValidPathUncached(const StorePath & path)
{
auto res = LocalStore::isValidPathUncached(path);
if (res) return res;
return lowerStore->isValidPath(path);
res = lowerStore->isValidPath(path);
if (res) {
// Get path info from lower store so upper DB genuinely has it.
LocalStore::registerValidPath(*lowerStore->queryPathInfo(path));
}
return res;
}
void LocalOverlayStore::registerValidPaths(const ValidPathInfos & infos)
{
// First, get any from lower store so we merge
{
StorePathSet notInUpper;
for (auto & [p, _] : infos)
if (!LocalStore::isValidPathUncached(p)) // avoid divergence
notInUpper.insert(p);
auto pathsInLower = lowerStore->queryValidPaths(notInUpper);
ValidPathInfos inLower;
for (auto & p : pathsInLower)
inLower.insert_or_assign(p, *lowerStore->queryPathInfo(p));
LocalStore::registerValidPaths(inLower);
}
// Then do original request
LocalStore::registerValidPaths(infos);
}

View file

@ -89,6 +89,8 @@ private:
bool isValidPathUncached(const StorePath & path) override;
void registerValidPaths(const ValidPathInfos & infos) override;
void addToStore(const ValidPathInfo & info, Source & source,
RepairFlag repair, CheckSigsFlag checkSigs) override;

View file

@ -232,7 +232,7 @@ public:
*/
void registerValidPath(const ValidPathInfo & info);
void registerValidPaths(const ValidPathInfos & infos);
virtual void registerValidPaths(const ValidPathInfos & infos);
unsigned int getProtocol() override;