mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-17 07:37:18 +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 {
|
namespace nix {
|
||||||
|
|
||||||
Path LocalOverlayStoreConfig::toUpperPath(const StorePath & path) {
|
Path LocalOverlayStoreConfig::toUpperPath(const StorePath & path) {
|
||||||
auto res = upperLayer + "/" + path.to_string();
|
return upperLayer + "/" + path.to_string();
|
||||||
warn("upper path: %s", res);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalOverlayStore::LocalOverlayStore(const Params & params)
|
LocalOverlayStore::LocalOverlayStore(const Params & params)
|
||||||
|
@ -91,7 +89,31 @@ bool LocalOverlayStore::isValidPathUncached(const StorePath & path)
|
||||||
{
|
{
|
||||||
auto res = LocalStore::isValidPathUncached(path);
|
auto res = LocalStore::isValidPathUncached(path);
|
||||||
if (res) return res;
|
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;
|
bool isValidPathUncached(const StorePath & path) override;
|
||||||
|
|
||||||
|
void registerValidPaths(const ValidPathInfos & infos) override;
|
||||||
|
|
||||||
void addToStore(const ValidPathInfo & info, Source & source,
|
void addToStore(const ValidPathInfo & info, Source & source,
|
||||||
RepairFlag repair, CheckSigsFlag checkSigs) override;
|
RepairFlag repair, CheckSigsFlag checkSigs) override;
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void registerValidPath(const ValidPathInfo & info);
|
void registerValidPath(const ValidPathInfo & info);
|
||||||
|
|
||||||
void registerValidPaths(const ValidPathInfos & infos);
|
virtual void registerValidPaths(const ValidPathInfos & infos);
|
||||||
|
|
||||||
unsigned int getProtocol() override;
|
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
|
nix-store --store "$storeA" --add dummy
|
||||||
|
|
||||||
# Build something in lower store
|
# 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 \
|
mount -t overlay overlay \
|
||||||
-o lowerdir="$storeA/nix/store" \
|
-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)
|
# upper layer should still not have it (no redundant copy)
|
||||||
expect 1 stat $(toRealPath "$storeB/nix/store" "$path")
|
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" --no-out-link)
|
||||||
##
|
|
||||||
## 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 lower layer (should fail)
|
|
||||||
## expect 1 stat $(toRealPath "$storeA/nix/store" "$path")
|
# Checking for path in upper layer
|
||||||
##
|
stat $(toRealPath "$storeBTop" "$path")
|
||||||
## # Checking for path in upper layer
|
|
||||||
## stat $(toRealPath "$storeBTop" "$path")
|
# Verifying path in overlay store
|
||||||
##
|
nix-store --verify-path --store "$storeB" "$path"
|
||||||
## # Verifying path in overlay store
|
|
||||||
## nix-store --verify-path --store "$storeB" "$path"
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue