aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/local-binary-cache-store.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/local-binary-cache-store.cc')
-rw-r--r--src/libstore/local-binary-cache-store.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc
index 91d2650fe..0f377989b 100644
--- a/src/libstore/local-binary-cache-store.cc
+++ b/src/libstore/local-binary-cache-store.cc
@@ -32,7 +32,19 @@ protected:
void upsertFile(const std::string & path, const std::string & data) override;
- std::shared_ptr<std::string> getFile(const std::string & path) override;
+ void getFile(const std::string & path,
+ std::function<void(std::shared_ptr<std::string>)> success,
+ std::function<void(std::exception_ptr exc)> failure) override
+ {
+ sync2async<std::shared_ptr<std::string>>(success, failure, [&]() {
+ try {
+ return std::make_shared<std::string>(readFile(binaryCacheDir + "/" + path));
+ } catch (SysError & e) {
+ if (e.errNo == ENOENT) return std::shared_ptr<std::string>();
+ throw;
+ }
+ });
+ }
PathSet queryAllValidPaths() override
{
@@ -76,16 +88,6 @@ void LocalBinaryCacheStore::upsertFile(const std::string & path, const std::stri
atomicWrite(binaryCacheDir + "/" + path, data);
}
-std::shared_ptr<std::string> LocalBinaryCacheStore::getFile(const std::string & path)
-{
- try {
- return std::make_shared<std::string>(readFile(binaryCacheDir + "/" + path));
- } catch (SysError & e) {
- if (e.errNo == ENOENT) return 0;
- throw;
- }
-}
-
static RegisterStoreImplementation regStore([](
const std::string & uri, const Store::Params & params)
-> std::shared_ptr<Store>