Provide function required by Hydra

This commit is contained in:
Eelco Dolstra 2016-03-02 18:21:48 +01:00
parent 25eea97873
commit 5a8455c85e
2 changed files with 16 additions and 3 deletions

View file

@ -65,13 +65,21 @@ std::string LocalBinaryCacheStore::getFile(const std::string & path)
return readFile(binaryCacheDir + "/" + path); return readFile(binaryCacheDir + "/" + path);
} }
ref<Store> openLocalBinaryCacheStore(std::shared_ptr<Store> localStore,
const Path & secretKeyFile, const Path & publicKeyFile,
const Path & binaryCacheDir)
{
auto store = std::make_shared<LocalBinaryCacheStore>(
localStore, secretKeyFile, publicKeyFile, binaryCacheDir);
store->init();
return ref<Store>(std::shared_ptr<Store>(store));
}
static RegisterStoreImplementation regStore([](const std::string & uri) -> std::shared_ptr<Store> { static RegisterStoreImplementation regStore([](const std::string & uri) -> std::shared_ptr<Store> {
if (std::string(uri, 0, 7) != "file://") return 0; if (std::string(uri, 0, 7) != "file://") return 0;
auto store = std::make_shared<LocalBinaryCacheStore>(std::shared_ptr<Store>(0), return openLocalBinaryCacheStore(std::shared_ptr<Store>(0),
"", "", // FIXME: allow the signing key to be set "", "", // FIXME: allow the signing key to be set
std::string(uri, 7)); std::string(uri, 7));
store->init();
return store;
}); });
} }

View file

@ -453,6 +453,11 @@ ref<Store> openStoreAt(const std::string & uri);
ref<Store> openStore(); ref<Store> openStore();
ref<Store> openLocalBinaryCacheStore(std::shared_ptr<Store> localStore,
const Path & secretKeyFile, const Path & publicKeyFile,
const Path & binaryCacheDir);
/* Store implementation registration. */ /* Store implementation registration. */
typedef std::function<std::shared_ptr<Store>(const std::string & uri)> OpenStore; typedef std::function<std::shared_ptr<Store>(const std::string & uri)> OpenStore;