diff options
author | Marius Bakke <mbakke@fastmail.com> | 2020-01-15 00:09:46 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-01-15 00:09:46 +0100 |
commit | 3cfe76bec06fbd8bb7e7cb3387866fefbcad674f (patch) | |
tree | b66780d205fb50fd44d0bbb38f5df99cf3167ba1 /nix/libstore/gc.cc | |
parent | ec836b46bf52a5f86c61f50e3a2c3330a7ee3665 (diff) | |
parent | 574a71a7a9668aa184661c58e1f18a4d4fccd792 (diff) | |
download | guix-patches-3cfe76bec06fbd8bb7e7cb3387866fefbcad674f.tar guix-patches-3cfe76bec06fbd8bb7e7cb3387866fefbcad674f.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'nix/libstore/gc.cc')
-rw-r--r-- | nix/libstore/gc.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc index 29b75aa875..77d7fa2dc7 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; } @@ -419,13 +426,14 @@ void LocalStore::deletePathRecursive(GCState & state, const Path & path) } if (state.options.maxFreed != ULLONG_MAX) { - double fraction = state.results.bytesFreed + size - / state.options.maxFreed; + auto freed = state.results.bytesFreed + state.bytesInvalidated; + double fraction = ((double) freed) / (double) state.options.maxFreed; unsigned int percentage = (fraction > 1. ? 1. : fraction) * 100.; printMsg(lvlInfo, format("[%1%%%] deleting '%2%'") % percentage % path); } else { - size_t total = (state.results.bytesFreed + size) / (1024 * 1024); - printMsg(lvlInfo, format("[%1% MiB] deleting '%2%'") % total % path); + auto freed = state.results.bytesFreed + state.bytesInvalidated; + freed /= 1024ULL * 1024ULL; + printMsg(lvlInfo, format("[%1% MiB] deleting '%2%'") % freed % path); } state.results.paths.insert(path); |