From 81ea8bd5ceb3dcae6af0b79c81a39ecbf2ba97a8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 27 Mar 2018 22:16:01 +0200 Subject: Simplify the callback mechanism --- src/libstore/local-binary-cache-store.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/libstore/local-binary-cache-store.cc') diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc index 2577e90aef23..ae0ffa6a56ef 100644 --- a/src/libstore/local-binary-cache-store.cc +++ b/src/libstore/local-binary-cache-store.cc @@ -35,17 +35,14 @@ protected: const std::string & mimeType) override; void getFile(const std::string & path, - std::function)> success, - std::function failure) override + Callback> callback) override { - sync2async>(success, failure, [&]() { - try { - return std::make_shared(readFile(binaryCacheDir + "/" + path)); - } catch (SysError & e) { - if (e.errNo == ENOENT) return std::shared_ptr(); - throw; - } - }); + try { + // FIXME: O(n) space + callback(std::make_shared(readFile(binaryCacheDir + "/" + path))); + } catch (SysError & e) { + if (e.errNo == ENOENT) callback(nullptr); else callback.rethrow(); + } catch (...) { callback.rethrow(); } } PathSet queryAllValidPaths() override -- cgit 1.4.1