mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 00:06:16 +02:00
Specialize more methods, fix tests
This commit is contained in:
parent
b3d320c594
commit
ddaf2750b5
4 changed files with 41 additions and 19 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ mkdir -p "$TEST_ROOT"/{store-a,store-b,merged-store/nix/store,workdir}
|
|||
nix-store --store "$storeA" --add dummy
|
||||
|
||||
# Build something in lower store
|
||||
path=$(nix-build ./hermetic.nix --arg busybox "$busybox" --arg seed 1 --store "$storeA")
|
||||
path=$(nix-build ./hermetic.nix --arg busybox "$busybox" --arg seed 1 --store "$storeA" --no-out-link)
|
||||
|
||||
mount -t overlay overlay \
|
||||
-o lowerdir="$storeA/nix/store" \
|
||||
|
@ -73,17 +73,15 @@ stat $(toRealPath "$storeA/nix/store" "$path")
|
|||
# upper layer should still not have it (no redundant copy)
|
||||
expect 1 stat $(toRealPath "$storeB/nix/store" "$path")
|
||||
|
||||
## Ooops something went wrong
|
||||
### Do a build in overlay store
|
||||
|
||||
## ### Do a build in overlay store
|
||||
##
|
||||
## path=$(nix-build ./hermetic.nix --arg busybox $busybox --arg seed 2 --store "$storeB")
|
||||
##
|
||||
## # Checking for path in lower layer (should fail)
|
||||
## expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
||||
##
|
||||
## # Checking for path in upper layer
|
||||
## stat $(toRealPath "$storeBTop" "$path")
|
||||
##
|
||||
## # Verifying path in overlay store
|
||||
## nix-store --verify-path --store "$storeB" "$path"
|
||||
path=$(nix-build ./hermetic.nix --arg busybox $busybox --arg seed 2 --store "$storeB" --no-out-link)
|
||||
|
||||
# Checking for path in lower layer (should fail)
|
||||
expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
||||
|
||||
# Checking for path in upper layer
|
||||
stat $(toRealPath "$storeBTop" "$path")
|
||||
|
||||
# Verifying path in overlay store
|
||||
nix-store --verify-path --store "$storeB" "$path"
|
||||
|
|
Loading…
Reference in a new issue