diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/nar-accessor.cc | 10 | ||||
-rw-r--r-- | src/libstore/nar-accessor.hh | 5 | ||||
-rw-r--r-- | src/nix/ls.cc | 2 |
4 files changed, 13 insertions, 6 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 9c6424a49..93caba67e 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -121,7 +121,7 @@ void BinaryCacheStore::addToStore(const ValidPathInfo & info, const ref<std::str { auto res = jsonRoot.placeholder("root"); - listNar(res, narAccessor, ""); + listNar(res, narAccessor, "", true); } } diff --git a/src/libstore/nar-accessor.cc b/src/libstore/nar-accessor.cc index b2d15c395..e5042208e 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; diff --git a/src/libstore/nar-accessor.hh b/src/libstore/nar-accessor.hh index 7699cbbb5..ed8fe15ca 100644 --- a/src/libstore/nar-accessor.hh +++ b/src/libstore/nar-accessor.hh @@ -10,6 +10,9 @@ ref<FSAccessor> makeNarAccessor(ref<const std::string> nar); class JSONPlaceholder; -void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor, const Path & path); +/* Write a JSON representation of the contents of a NAR (except file + contents). */ +void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor, + const Path & path, bool recurse); } diff --git a/src/nix/ls.cc b/src/nix/ls.cc index 5408c0929..69620595d 100644 --- a/src/nix/ls.cc +++ b/src/nix/ls.cc @@ -77,7 +77,7 @@ struct MixLs : virtual Args, MixJSON if (json) { JSONPlaceholder jsonRoot(std::cout); - listNar(jsonRoot, accessor, path); + listNar(jsonRoot, accessor, path, recursive); } else listText(accessor); } |