From 5059be53b1553f99b95f31227998de69ecf74d90 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 9 May 2023 16:42:28 -0400 Subject: [PATCH] Fix recursive ingestion from lower store --- src/libstore/local-overlay-store.cc | 7 ++++++- tests/overlay-local-store/inner.sh | 15 +++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/libstore/local-overlay-store.cc b/src/libstore/local-overlay-store.cc index cb409c2bd..431b82c90 100644 --- a/src/libstore/local-overlay-store.cc +++ b/src/libstore/local-overlay-store.cc @@ -92,7 +92,12 @@ bool LocalOverlayStore::isValidPathUncached(const StorePath & path) res = lowerStore->isValidPath(path); if (res) { // Get path info from lower store so upper DB genuinely has it. - LocalStore::registerValidPath(*lowerStore->queryPathInfo(path)); + auto p = lowerStore->queryPathInfo(path); + // recur on references, syncing entire closure. + for (auto & r : p->references) + if (r != path) + isValidPath(r); + LocalStore::registerValidPath(*p); } return res; } diff --git a/tests/overlay-local-store/inner.sh b/tests/overlay-local-store/inner.sh index 279f005a9..1cb29ceb7 100755 --- a/tests/overlay-local-store/inner.sh +++ b/tests/overlay-local-store/inner.sh @@ -22,7 +22,8 @@ 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" --no-out-link) +drvPath=$(nix-instantiate --store $storeA ./hermetic.nix --arg busybox "$busybox" --arg seed 1) +path=$(nix-store --store "$storeA" --realise $drvPath) mount -t overlay overlay \ -o lowerdir="$storeA/nix/store" \ @@ -38,9 +39,9 @@ cleanupOverlay () { trap cleanupOverlay EXIT toRealPath () { - storeDir=$1; shift - storePath=$1; shift - echo $storeDir$(echo $storePath | sed "s^$NIX_STORE_DIR^^") + storeDir=$1; shift + storePath=$1; shift + echo $storeDir$(echo $storePath | sed "s^$NIX_STORE_DIR^^") } ### Check status @@ -60,6 +61,12 @@ nix-store --verify-path --store "$storeA" "$path" # Verifying path in merged-store nix-store --verify-path --store "$storeB" "$path" +[[ \ + $(nix-store --store $storeA --query --outputs $drvPath) \ + == \ + $(nix-store --store $storeB --query --outputs $drvPath) \ + ]] + hashPart=$(echo $path | sed "s^$NIX_STORE_DIR/^^" | sed 's/-.*//') # Lower store can find from hash part