diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-11-14T13·31+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-11-14T13·31+0100 |
commit | 4db0a9555e3b39600847084e1b40e0bb935c13de (patch) | |
tree | 494236487cc8c250394cd9e25b7fefa6f257d40f /src/libstore/nar-accessor.cc | |
parent | c8155e9f5fba14c4edc8c5763fb7d7e9d4d123a9 (diff) |
nix ls-{nar,store} --json: Respect -R
Diffstat (limited to 'src/libstore/nar-accessor.cc')
-rw-r--r-- | src/libstore/nar-accessor.cc | 10 |
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; |