Skip to content

Commit e541f5a

Browse files
committed
Fix test
1 parent 46878c1 commit e541f5a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/libstore/gc.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,15 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
717717
} catch (InvalidPath &) { }
718718
};
719719

720+
if (options.action == GCOptions::gcDeleteSpecific
721+
&& !options.pathsToDelete.count(*path))
722+
{
723+
throw Error(
724+
"Cannot delete path '%s' because it's referenced by path '%s'.",
725+
printStorePath(start),
726+
printStorePath(*path));
727+
}
728+
720729
/* If this is a root, bail out. */
721730
if (auto i = roots.find(*path); i != roots.end()) {
722731
if (options.action == GCOptions::gcDeleteSpecific)
@@ -728,15 +737,6 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
728737
return markAlive();
729738
}
730739

731-
if (options.action == GCOptions::gcDeleteSpecific
732-
&& !options.pathsToDelete.count(*path))
733-
{
734-
throw Error(
735-
"Cannot delete path '%s' because it's referenced by path '%s'.",
736-
printStorePath(start),
737-
printStorePath(*path));
738-
}
739-
740740
{
741741
auto hashPart = std::string(path->hashPart());
742742
auto shared(_shared.lock());

tests/functional/gc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if nix-store --gc --print-dead | grep -E "$outPath"$; then false; fi
2323
nix-store --gc --print-dead
2424

2525
inUse=$(readLink "$outPath/reference-to-input-2")
26-
expectStderr 1 nix-store --delete "$inUse" | grepQuiet "Cannot delete path.*because it's referenced by the GC root "
26+
expectStderr 1 nix-store --delete "$inUse" | grepQuiet "Cannot delete path.*because it's referenced by path '"
2727
test -e "$inUse"
2828

2929
expectStderr 1 nix-store --delete "$outPath" | grepQuiet "Cannot delete path.*because it's referenced by the GC root "

0 commit comments

Comments
 (0)