From 8f829e478fee2f0912be6b7c01ac5dc3b18b07d5 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 12 Jan 2026 23:20:08 -0500 Subject: [PATCH] Inline `RemoteFSAccessor::makeCacheFile` into lambda It's just easier to avoid headers. --- .../include/nix/store/remote-fs-accessor.hh | 2 -- src/libstore/remote-fs-accessor.cc | 20 +++++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/libstore/include/nix/store/remote-fs-accessor.hh b/src/libstore/include/nix/store/remote-fs-accessor.hh index 62f4dd726..479a73932 100644 --- a/src/libstore/include/nix/store/remote-fs-accessor.hh +++ b/src/libstore/include/nix/store/remote-fs-accessor.hh @@ -31,8 +31,6 @@ class RemoteFSAccessor : public SourceAccessor friend struct BinaryCacheStore; - std::filesystem::path makeCacheFile(const Hash & narHash, const std::string & ext); - public: /** diff --git a/src/libstore/remote-fs-accessor.cc b/src/libstore/remote-fs-accessor.cc index 1af82d279..88a5083dd 100644 --- a/src/libstore/remote-fs-accessor.cc +++ b/src/libstore/remote-fs-accessor.cc @@ -18,15 +18,6 @@ RemoteFSAccessor::RemoteFSAccessor( createDirs(*cacheDir); } -std::filesystem::path RemoteFSAccessor::makeCacheFile(const Hash & narHash, const std::string & ext) -{ - assert(cacheDir); - auto res = *cacheDir / narHash.to_string(HashFormat::Nix32, false); - res += "."; - res += ext; - return res; -} - std::pair, CanonPath> RemoteFSAccessor::fetch(const CanonPath & path) { auto [storePath, restPath] = store->toStorePath(store->storeDir + path.abs()); @@ -57,8 +48,15 @@ std::shared_ptr RemoteFSAccessor::accessObject(const StorePath & }; if (cacheDir) { - auto cacheFile = makeCacheFile(info->narHash, "nar"); - auto listingFile = makeCacheFile(info->narHash, "ls"); + auto makeCacheFile = [&](const std::string & ext) { + auto res = *cacheDir / info->narHash.to_string(HashFormat::Nix32, false); + res += "."; + res += ext; + return res; + }; + + auto cacheFile = makeCacheFile("nar"); + auto listingFile = makeCacheFile("ls"); if (nix::pathExists(cacheFile)) { try {