From 44f6e6de77dd318800775d594b1f33cffa2be9a5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 8 Mar 2010 21:31:42 +0000 Subject: [PATCH] * Set `gc-keep-outputs' or `gc-keep-derivations' to false with `--delete --ignore-liveness'. --- src/libstore/gc.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index cf073c5d9a..87e0a05bc9 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -563,6 +563,15 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) state.gcKeepOutputs = queryBoolSetting("gc-keep-outputs", false); state.gcKeepDerivations = queryBoolSetting("gc-keep-derivations", true); + + /* Using `--ignore-liveness' with `--delete' can have unintended + consequences if `gc-keep-outputs' or `gc-keep-derivations' are + true (the garbage collector will recurse into deleting the + outputs or derivers, respectively). So disable them. */ + if (options.action == GCOptions::gcDeleteSpecific && options.ignoreLiveness) { + state.gcKeepOutputs = false; + state.gcKeepDerivations = false; + } /* Acquire the global GC root. This prevents a) New roots from being added.