importPaths(): Fix accessor support for Hydra

This commit is contained in:
Eelco Dolstra 2016-10-07 18:13:40 +02:00
parent b0f7f9c98f
commit 629ab80022
4 changed files with 27 additions and 7 deletions

View file

@ -318,4 +318,12 @@ ref<FSAccessor> BinaryCacheStore::getFSAccessor()
std::dynamic_pointer_cast<BinaryCacheStore>(shared_from_this()))); 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));
}
} }

View file

@ -134,6 +134,12 @@ public:
ref<FSAccessor> getFSAccessor() override; 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 void addSignatures(const Path & storePath, const StringSet & sigs) override
{ notImpl(); } { notImpl(); }

View file

@ -119,13 +119,8 @@ Paths Store::importPaths(Source & source, std::shared_ptr<FSAccessor> accessor,
addToStore(info, *tee.data, false, dontCheckSigs); addToStore(info, *tee.data, false, dontCheckSigs);
// FIXME: implement accessors? if (accessor)
assert(!accessor); addPathToAccessor(ref<FSAccessor>(accessor), info.path, tee.data);
#if 0
auto accessor_ = std::dynamic_pointer_cast<BinaryCacheStoreAccessor>(accessor);
if (accessor_)
accessor_->nars.emplace(info.path, makeNarAccessor(tee.data));
#endif
res.push_back(info.path); res.push_back(info.path);
} }

View file

@ -461,6 +461,17 @@ public:
/* Return an object to access files in the Nix store. */ /* Return an object to access files in the Nix store. */
virtual ref<FSAccessor> getFSAccessor() = 0; 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 /* Add signatures to the specified store path. The signatures are
not verified. */ not verified. */
virtual void addSignatures(const Path & storePath, const StringSet & sigs) = 0; virtual void addSignatures(const Path & storePath, const StringSet & sigs) = 0;