Skip to content

Commit ac36d74

Browse files
committed
listNar should just take the source accessor by simple reference
A shared pointer is not needed.
1 parent d17bfe3 commit ac36d74

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/libstore/binary-cache-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
208208
if (config.writeNARListing) {
209209
nlohmann::json j = {
210210
{"version", 1},
211-
{"root", listNar(ref<SourceAccessor>(narAccessor), CanonPath::root, true)},
211+
{"root", listNar(*narAccessor, CanonPath::root, true)},
212212
};
213213

214214
upsertFile(std::string(info.path.hashPart()) + ".ls", j.dump(), "application/json");

src/libstore/remote-fs-accessor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ref<SourceAccessor> RemoteFSAccessor::addToCache(std::string_view hashPart, std:
3939

4040
if (cacheDir != "") {
4141
try {
42-
nlohmann::json j = listNar(narAccessor, CanonPath::root, true);
42+
nlohmann::json j = listNar(*narAccessor, CanonPath::root, true);
4343
writeFile(makeCacheFile(hashPart, "ls"), j.dump());
4444
} catch (...) {
4545
ignoreExceptionExceptInterrupt();

src/libutil/include/nix/util/nar-accessor.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ ref<SourceAccessor> makeLazyNarAccessor(const nlohmann::json & listing, GetNarBy
3838
* Write a JSON representation of the contents of a NAR (except file
3939
* contents).
4040
*/
41-
nlohmann::json listNar(ref<SourceAccessor> accessor, const CanonPath & path, bool recurse);
41+
nlohmann::json listNar(SourceAccessor & accessor, const CanonPath & path, bool recurse);
4242

4343
} // namespace nix

src/libutil/nar-accessor.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ GetNarBytes seekableGetNarBytes(const Path & path)
274274

275275
using nlohmann::json;
276276

277-
json listNar(ref<SourceAccessor> accessor, const CanonPath & path, bool recurse)
277+
json listNar(SourceAccessor & accessor, const CanonPath & path, bool recurse)
278278
{
279-
auto st = accessor->lstat(path);
279+
auto st = accessor.lstat(path);
280280

281281
json obj = json::object();
282282

@@ -295,7 +295,7 @@ json listNar(ref<SourceAccessor> accessor, const CanonPath & path, bool recurse)
295295
{
296296
obj["entries"] = json::object();
297297
json & res2 = obj["entries"];
298-
for (const auto & [name, type] : accessor->readDirectory(path)) {
298+
for (const auto & [name, type] : accessor.readDirectory(path)) {
299299
if (recurse) {
300300
res2[name] = listNar(accessor, path / name, true);
301301
} else
@@ -305,7 +305,7 @@ json listNar(ref<SourceAccessor> accessor, const CanonPath & path, bool recurse)
305305
break;
306306
case SourceAccessor::Type::tSymlink:
307307
obj["type"] = "symlink";
308-
obj["target"] = accessor->readLink(path);
308+
obj["target"] = accessor.readLink(path);
309309
break;
310310
case SourceAccessor::Type::tBlock:
311311
case SourceAccessor::Type::tChar:

src/nix/cat.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct CmdCatNar : StoreCommand, MixCat
8080
throw SysError("opening NAR file '%s'", narPath);
8181
auto source = FdSource{fd.get()};
8282
auto narAccessor = makeNarAccessor(source);
83-
auto listing = listNar(narAccessor, CanonPath::root, true);
83+
auto listing = listNar(*narAccessor, CanonPath::root, true);
8484
cat(makeLazyNarAccessor(listing, seekableGetNarBytes(narPath)), CanonPath{path});
8585
}
8686
};

src/nix/ls.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct MixLs : virtual Args, MixJSON
8585
if (json) {
8686
if (showDirectory)
8787
throw UsageError("'--directory' is useless with '--json'");
88-
logger->cout("%s", listNar(accessor, path, recursive));
88+
logger->cout("%s", listNar(*accessor, path, recursive));
8989
} else
9090
listText(accessor, std::move(path));
9191
}
@@ -150,7 +150,7 @@ struct CmdLsNar : Command, MixLs
150150
throw SysError("opening NAR file '%s'", narPath);
151151
auto source = FdSource{fd.get()};
152152
auto narAccessor = makeNarAccessor(source);
153-
auto listing = listNar(narAccessor, CanonPath::root, true);
153+
auto listing = listNar(*narAccessor, CanonPath::root, true);
154154
list(makeLazyNarAccessor(listing, seekableGetNarBytes(narPath)), CanonPath{path});
155155
}
156156
};

0 commit comments

Comments
 (0)