about summary refs log tree commit diff
path: root/src/libstore/nar-accessor.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-11-14T13·31+0100
committerEelco Dolstra <edolstra@gmail.com>2017-11-14T13·31+0100
commit4db0a9555e3b39600847084e1b40e0bb935c13de (patch)
tree494236487cc8c250394cd9e25b7fefa6f257d40f /src/libstore/nar-accessor.cc
parentc8155e9f5fba14c4edc8c5763fb7d7e9d4d123a9 (diff)
nix ls-{nar,store} --json: Respect -R
Diffstat (limited to 'src/libstore/nar-accessor.cc')
-rw-r--r--src/libstore/nar-accessor.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstore/nar-accessor.cc b/src/libstore/nar-accessor.cc
index b2d15c395f10..e5042208e58b 100644
--- a/src/libstore/nar-accessor.cc
+++ b/src/libstore/nar-accessor.cc
@@ -182,7 +182,8 @@ ref<FSAccessor> makeNarAccessor(ref<const std::string> nar)
     return make_ref<NarAccessor>(nar);
 }
 
-void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor, const Path & path)
+void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor,
+    const Path & path, bool recurse)
 {
     auto st = accessor->stat(path);
 
@@ -200,8 +201,11 @@ void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor, const Path & path)
         {
             auto res2 = obj.object("entries");
             for (auto & name : accessor->readDirectory(path)) {
-                auto res3 = res2.placeholder(name);
-                listNar(res3, accessor, path + "/" + name);
+                if (recurse) {
+                    auto res3 = res2.placeholder(name);
+                    listNar(res3, accessor, path + "/" + name, true);
+                } else
+                    res2.object(name);
             }
         }
         break;