diff options
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 8 | ||||
-rw-r--r-- | src/libstore/binary-cache-store.hh | 6 | ||||
-rw-r--r-- | src/libstore/export-import.cc | 9 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 11 |
4 files changed, 27 insertions, 7 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 0ffbd6e552b7..01d1a7e246d9 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -318,4 +318,12 @@ ref<FSAccessor> BinaryCacheStore::getFSAccessor() std::dynamic_pointer_cast<BinaryCacheStore>(shared_from_this()))); } +void BinaryCacheStore::addPathToAccessor(ref<FSAccessor> accessor, + const Path & storePath, const ref<std::string> & data) +{ + auto accessor_ = accessor.dynamic_pointer_cast<BinaryCacheStoreAccessor>(); + if (accessor_) + accessor_->nars.emplace(storePath, makeNarAccessor(data)); +} + } diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh index 41671b7d9ffd..e369abe46d6f 100644 --- a/src/libstore/binary-cache-store.hh +++ b/src/libstore/binary-cache-store.hh @@ -134,6 +134,12 @@ public: ref<FSAccessor> getFSAccessor() override; +private: + + void addPathToAccessor(ref<FSAccessor>, const Path & storePath, const ref<std::string> & data) override; + +public: + void addSignatures(const Path & storePath, const StringSet & sigs) override { notImpl(); } diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc index 6090ee3e9f83..b7f43acf1dc2 100644 --- a/src/libstore/export-import.cc +++ b/src/libstore/export-import.cc @@ -119,13 +119,8 @@ Paths Store::importPaths(Source & source, std::shared_ptr<FSAccessor> accessor, addToStore(info, *tee.data, false, dontCheckSigs); - // FIXME: implement accessors? - assert(!accessor); -#if 0 - auto accessor_ = std::dynamic_pointer_cast<BinaryCacheStoreAccessor>(accessor); - if (accessor_) - accessor_->nars.emplace(info.path, makeNarAccessor(tee.data)); -#endif + if (accessor) + addPathToAccessor(ref<FSAccessor>(accessor), info.path, tee.data); res.push_back(info.path); } diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index cba4deaad5d7..8efacfd18ecc 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -461,6 +461,17 @@ public: /* Return an object to access files in the Nix store. */ virtual ref<FSAccessor> getFSAccessor() = 0; +private: + + /* Inform an accessor about the NAR contents of a store path. Used + by importPaths() to speed up subsequent access to the imported + paths when used with binary cache stores. */ + virtual void addPathToAccessor(ref<FSAccessor>, const Path & storePath, const ref<std::string> & data) + { + } + +public: + /* Add signatures to the specified store path. The signatures are not verified. */ virtual void addSignatures(const Path & storePath, const StringSet & sigs) = 0; |