diff options
author | Sergei Trofimovich <slyich@gmail.com> | 2022-03-12 21:56:08 +0000 |
---|---|---|
committer | Sergei Trofimovich <slyich@gmail.com> | 2022-03-13 07:24:48 +0000 |
commit | 6b1872312f1b505334acb67b8bf7990b0a0fdbd8 (patch) | |
tree | 24eb7c1aa698cfadf8249dfa0cf0afe69f00686d /src/libstore/gc.cc | |
parent | d5322698a2abbc6d141e1d244e17b0d226a2f18b (diff) |
nix store gc: account for auto-optimised store
Before the change on a system with `auto-optimise-store = true`:
$ nix store gc --verbose --max 1
deleted all the paths instead of one path (we requested 1 byte limit).
It happens because every file in `auto-optimise-store = true` has at
least 2 links: file itself and a link in /nix/store/.links/ directory.
The change conservatively assumes that any file that has one (as before)
or two links (assume auto-potimise mode) will free space.
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r-- | src/libstore/gc.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 024da66c1..69755bd19 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -841,7 +841,8 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) if (unlink(path.c_str()) == -1) throw SysError("deleting '%1%'", path); - results.bytesFreed += st.st_size; + /* Do not accound for deleted file here. Rely on deletePath() + accounting. */ } struct stat st; |