From 53522cb6ac19bd1da35a657988231cce9387be9c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 14 Mar 2019 13:50:07 +0100 Subject: findRoots(): Add 'censor' parameter This is less brittle than filtering paths after the fact in nix-daemon. --- src/nix-daemon/nix-daemon.cc | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) (limited to 'src/nix-daemon/nix-daemon.cc') 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, 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; } -- cgit 1.4.1