about summary refs log tree commit diff
path: root/src/nix-daemon
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-03-14T12·50+0100
committerEelco Dolstra <edolstra@gmail.com>2019-03-14T12·53+0100
commit53522cb6ac19bd1da35a657988231cce9387be9c (patch)
tree7ba80ef40ac8ad2c93c9216d08321642049b71e2 /src/nix-daemon
parenta3f37d87eabcfb5dc581abcfa46e5e7d387dfa8c (diff)
findRoots(): Add 'censor' parameter
This is less brittle than filtering paths after the fact in
nix-daemon.
Diffstat (limited to 'src/nix-daemon')
-rw-r--r--src/nix-daemon/nix-daemon.cc41
1 files changed, 10 insertions, 31 deletions
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 0feafb01385b..dd8b9bd1e89f 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -475,40 +475,19 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
 
     case wopFindRoots: {
         logger->startWork();
-        Roots roots = store->findRoots();
+        Roots roots = store->findRoots(true);
         logger->stopWork();
 
-        // Pre-compute roots length using same algo as below.
-        size_t total_length = 0;
-        bool hasMemoryLink;
-        for (auto & root : roots) {
-            hasMemoryLink = false;
-            for (auto & link : root.second) {
-                if (link.rfind("{memory:", 0) == 0) {
-                    if (hasMemoryLink) continue;
-                    ++total_length;
-                    hasMemoryLink = true;
-                } else {
-                    ++total_length;
-                }
-            }
-        }
+        size_t size = 0;
+        for (auto & i : roots)
+            size += i.second.size();
+
+        to << size;
+
+        for (auto & [target, links] : roots)
+            for (auto & link : links)
+                to << link << target;
 
-        to << total_length;
-        int n = 0;
-        for (auto & [target, links] : roots) {
-            bool hasMemoryLink = false;
-            for (auto & link : links) {
-                // Obfuscate 'memory' roots as they expose information about other users,
-                if (link.rfind("{memory:", 0) == 0) {
-                    if (hasMemoryLink) continue;
-                    to << fmt("{memory:%d}", n++) << target;
-                    hasMemoryLink = true;
-                } else {
-                    to << link << target;
-                }
-            }
-        }
         break;
     }