aboutsummaryrefslogtreecommitdiff
path: root/nix/libstore/gc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'nix/libstore/gc.cc')
-rw-r--r--nix/libstore/gc.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index 29b75aa875..5043963fa2 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -392,7 +392,14 @@ bool LocalStore::isActiveTempFile(const GCState & state,
void LocalStore::deleteGarbage(GCState & state, const Path & path)
{
unsigned long long bytesFreed;
- deletePath(path, bytesFreed);
+
+ /* When deduplication is on, store items always have at least two links:
+ the one at PATH, and one in /gnu/store/.links. In that case, increase
+ bytesFreed when PATH has two or fewer links. */
+ size_t linkThreshold =
+ (settings.autoOptimiseStore && isStorePath(path)) ? 2 : 1;
+
+ deletePath(path, bytesFreed, linkThreshold);
state.results.bytesFreed += bytesFreed;
}