From e1df6c220ac153ccae8f2e5bcb7969c034bc10ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 11 Apr 2022 10:20:36 +0200 Subject: [PATCH] =?UTF-8?q?Censor=20the=20gc=20roots=20that=20aren?= =?UTF-8?q?=E2=80=99t=20under=20`stateDir`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libstore/gc.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 1499296fb..14b559c1e 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -340,11 +340,13 @@ Roots LocalStore::findRoots(bool censor) if (parsedLine.size() != 2) throw Error("Invalid result from the gc helper"); auto rawDestPath = parsedLine[0]; + auto retainer = parsedLine[1]; if (!isInStore(rawDestPath)) continue; try { auto destPath = toStorePath(rawDestPath).first; if (!isValidPath(destPath)) continue; - roots[destPath].insert(parsedLine[1]); + roots[destPath].insert( + (!censor || isInDir(retainer, stateDir)) ? retainer : censored); } catch (Error &) { } }