From d0a699da9b2689b3367ba0354ba580069a6268d9 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 22 Aug 2018 09:11:36 +0200 Subject: Remove "__internal_dbname" check (doesn't work with integer keys) --- common/storage_lmdb.cpp | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index 6f2142f..0458dae 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp @@ -477,7 +477,7 @@ int DataStore::NamedDatabase::scan(const size_t key, { return scan(sizeTToByteArray(key), [&resultHandler](const QByteArray &key, const QByteArray &value) { - return resultHandler(byteArrayToSizeT(value), value); + return resultHandler(byteArrayToSizeT(key), value); }, errorHandler, /* findSubstringKeys = */ false, skipInternalKeys); } @@ -901,29 +901,6 @@ void DataStore::Transaction::abort() d->transaction = nullptr; } -//Ensure that we opened the correct database by comparing the expected identifier with the one -//we write to the database on first open. -static bool ensureCorrectDb(DataStore::NamedDatabase &database, const QByteArray &db, bool readOnly) -{ - bool openedTheWrongDatabase = false; - auto count = database.scan("__internal_dbname", [db, &openedTheWrongDatabase](const QByteArray &key, const QByteArray &value) ->bool { - if (value != db) { - SinkWarning() << "Opened the wrong database, got " << value << " instead of " << db; - openedTheWrongDatabase = true; - } - return false; - }, - [&](const DataStore::Error &) { - }, false); - //This is the first time we open this database in a write transaction, write the db name - if (!count) { - if (!readOnly) { - database.write("__internal_dbname", db); - } - } - return !openedTheWrongDatabase; -} - DataStore::NamedDatabase DataStore::Transaction::openDatabase(const QByteArray &db, const std::function &errorHandler, int flags) const { @@ -947,11 +924,6 @@ DataStore::NamedDatabase DataStore::Transaction::openDatabase(const QByteArray & } auto database = DataStore::NamedDatabase(p); - if (!ensureCorrectDb(database, db, d->requestedRead)) { - SinkWarning() << "Failed to open the database correctly" << db; - Q_ASSERT(false); - return DataStore::NamedDatabase(); - } return database; } -- cgit v1.2.3