1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-24 03:09:35 +01:00
This commit is contained in:
Eelco Dolstra 2025-06-30 11:30:24 +02:00
parent 5b23885216
commit 2059f72d02
2 changed files with 10 additions and 10 deletions

View file

@ -717,6 +717,15 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
} catch (InvalidPath &) { }
};
if (options.action == GCOptions::gcDeleteSpecific
&& !options.pathsToDelete.count(*path))
{
throw Error(
"Cannot delete path '%s' because it's referenced by path '%s'.",
printStorePath(start),
printStorePath(*path));
}
/* If this is a root, bail out. */
if (auto i = roots.find(*path); i != roots.end()) {
if (options.action == GCOptions::gcDeleteSpecific)
@ -728,15 +737,6 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
return markAlive();
}
if (options.action == GCOptions::gcDeleteSpecific
&& !options.pathsToDelete.count(*path))
{
throw Error(
"Cannot delete path '%s' because it's referenced by path '%s'.",
printStorePath(start),
printStorePath(*path));
}
{
auto hashPart = std::string(path->hashPart());
auto shared(_shared.lock());