From 629ab8002218e9b526d947a9b7a2eccddc3f331c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 7 Oct 2016 18:13:40 +0200 Subject: importPaths(): Fix accessor support for Hydra --- src/libstore/binary-cache-store.cc | 8 ++++++++ src/libstore/binary-cache-store.hh | 6 ++++++ src/libstore/export-import.cc | 9 ++------- src/libstore/store-api.hh | 11 +++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src') 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 BinaryCacheStore::getFSAccessor() std::dynamic_pointer_cast(shared_from_this()))); } +void BinaryCacheStore::addPathToAccessor(ref accessor, + const Path & storePath, const ref & data) +{ + auto accessor_ = accessor.dynamic_pointer_cast(); + 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 getFSAccessor() override; +private: + + void addPathToAccessor(ref, const Path & storePath, const ref & 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 accessor, addToStore(info, *tee.data, false, dontCheckSigs); - // FIXME: implement accessors? - assert(!accessor); -#if 0 - auto accessor_ = std::dynamic_pointer_cast(accessor); - if (accessor_) - accessor_->nars.emplace(info.path, makeNarAccessor(tee.data)); -#endif + if (accessor) + addPathToAccessor(ref(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 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, const Path & storePath, const ref & data) + { + } + +public: + /* Add signatures to the specified store path. The signatures are not verified. */ virtual void addSignatures(const Path & storePath, const StringSet & sigs) = 0; -- cgit 1.4.1