diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 3cf2da70d..49077524f 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -208,7 +208,7 @@ ref BinaryCacheStore::addToStoreCommon( if (config.writeNARListing) { nlohmann::json j = { {"version", 1}, - {"root", listNar(ref(narAccessor), CanonPath::root, true)}, + {"root", listNar(*narAccessor, CanonPath::root, true)}, }; upsertFile(std::string(info.path.hashPart()) + ".ls", j.dump(), "application/json"); diff --git a/src/libstore/remote-fs-accessor.cc b/src/libstore/remote-fs-accessor.cc index 582599f0d..e2c8f65a7 100644 --- a/src/libstore/remote-fs-accessor.cc +++ b/src/libstore/remote-fs-accessor.cc @@ -39,7 +39,7 @@ ref RemoteFSAccessor::addToCache(std::string_view hashPart, std: if (cacheDir != "") { try { - nlohmann::json j = listNar(narAccessor, CanonPath::root, true); + nlohmann::json j = listNar(*narAccessor, CanonPath::root, true); writeFile(makeCacheFile(hashPart, "ls"), j.dump()); } catch (...) { ignoreExceptionExceptInterrupt(); diff --git a/src/libutil/include/nix/util/nar-accessor.hh b/src/libutil/include/nix/util/nar-accessor.hh index bfba5da73..df7b0fcf2 100644 --- a/src/libutil/include/nix/util/nar-accessor.hh +++ b/src/libutil/include/nix/util/nar-accessor.hh @@ -38,6 +38,6 @@ ref makeLazyNarAccessor(const nlohmann::json & listing, GetNarBy * Write a JSON representation of the contents of a NAR (except file * contents). */ -nlohmann::json listNar(ref accessor, const CanonPath & path, bool recurse); +nlohmann::json listNar(SourceAccessor & accessor, const CanonPath & path, bool recurse); } // namespace nix diff --git a/src/libutil/nar-accessor.cc b/src/libutil/nar-accessor.cc index 6bcdf5f13..12db8ac7b 100644 --- a/src/libutil/nar-accessor.cc +++ b/src/libutil/nar-accessor.cc @@ -274,9 +274,9 @@ GetNarBytes seekableGetNarBytes(const Path & path) using nlohmann::json; -json listNar(ref accessor, const CanonPath & path, bool recurse) +json listNar(SourceAccessor & accessor, const CanonPath & path, bool recurse) { - auto st = accessor->lstat(path); + auto st = accessor.lstat(path); json obj = json::object(); @@ -295,7 +295,7 @@ json listNar(ref accessor, const CanonPath & path, bool recurse) { obj["entries"] = json::object(); json & res2 = obj["entries"]; - for (const auto & [name, type] : accessor->readDirectory(path)) { + for (const auto & [name, type] : accessor.readDirectory(path)) { if (recurse) { res2[name] = listNar(accessor, path / name, true); } else @@ -305,7 +305,7 @@ json listNar(ref accessor, const CanonPath & path, bool recurse) break; case SourceAccessor::Type::tSymlink: obj["type"] = "symlink"; - obj["target"] = accessor->readLink(path); + obj["target"] = accessor.readLink(path); break; case SourceAccessor::Type::tBlock: case SourceAccessor::Type::tChar: diff --git a/src/nix/cat.cc b/src/nix/cat.cc index 114e8d38e..5c3d7cfd4 100644 --- a/src/nix/cat.cc +++ b/src/nix/cat.cc @@ -80,7 +80,7 @@ struct CmdCatNar : StoreCommand, MixCat throw SysError("opening NAR file '%s'", narPath); auto source = FdSource{fd.get()}; auto narAccessor = makeNarAccessor(source); - auto listing = listNar(narAccessor, CanonPath::root, true); + auto listing = listNar(*narAccessor, CanonPath::root, true); cat(makeLazyNarAccessor(listing, seekableGetNarBytes(narPath)), CanonPath{path}); } }; diff --git a/src/nix/ls.cc b/src/nix/ls.cc index ca6e20be8..ccd479c0a 100644 --- a/src/nix/ls.cc +++ b/src/nix/ls.cc @@ -85,7 +85,7 @@ struct MixLs : virtual Args, MixJSON if (json) { if (showDirectory) throw UsageError("'--directory' is useless with '--json'"); - logger->cout("%s", listNar(accessor, path, recursive)); + logger->cout("%s", listNar(*accessor, path, recursive)); } else listText(accessor, std::move(path)); } @@ -150,7 +150,7 @@ struct CmdLsNar : Command, MixLs throw SysError("opening NAR file '%s'", narPath); auto source = FdSource{fd.get()}; auto narAccessor = makeNarAccessor(source); - auto listing = listNar(narAccessor, CanonPath::root, true); + auto listing = listNar(*narAccessor, CanonPath::root, true); list(makeLazyNarAccessor(listing, seekableGetNarBytes(narPath)), CanonPath{path}); } };