From 600df6d2ec84df5238781f1274b6f5ff31a34646 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 2 Oct 2020 16:39:20 +0200 Subject: [PATCH] Fix fetching inexistent batch tokens --- src/Cache.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Cache.cpp b/src/Cache.cpp index 8b47c35..b7a2534 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -687,11 +687,14 @@ Cache::nextBatchToken() const auto txn = lmdb::txn::begin(env_, nullptr, MDB_RDONLY); lmdb::val token; - lmdb::dbi_get(txn, syncStateDb_, NEXT_BATCH_KEY, token); + auto result = lmdb::dbi_get(txn, syncStateDb_, NEXT_BATCH_KEY, token); txn.commit(); - return std::string(token.data(), token.size()); + if (result) + return std::string(token.data(), token.size()); + else + return ""; } void