daemon: Do not deduplicate files smaller than 8 KiB.
[jackhill/guix/guix.git] / nix / libstore / gc.cc
index e1d0765..1651911 100644 (file)
@@ -606,7 +606,9 @@ void LocalStore::removeUnusedLinks(const GCState & state)
             throw SysError(format("statting `%1%'") % path);
 #endif
 
-        if (st.st_nlink != 1) {
+       /* Drop links for files smaller than 'deduplicationMinSize', even if
+          they have more than one hard link.  */
+        if (st.st_nlink != 1 && st.st_size >= deduplicationMinSize) {
             actualSize += st.st_size;
             unsharedSize += (st.st_nlink - 1) * st.st_size;
             continue;