From 874b0d2be32e2edffedd59ab17bf821456757e29 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 26 Jun 2016 14:40:13 +0200 Subject: Avoid unnecesary warnings --- common/pipeline.cpp | 12 +++++++----- common/queryrunner.cpp | 5 +++++ common/storage_lmdb.cpp | 8 +++++++- 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/pipeline.cpp b/common/pipeline.cpp index e3b9180..976a83f 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -115,11 +115,13 @@ void Pipeline::startTransaction() //FIXME this is a temporary measure to recover from a failure to open the named databases correctly. //Once the actual problem is fixed it will be enough to simply crash if we open the wrong database (which we check in openDatabase already). //It seems like the validateNamedDatabase calls actually stops the mdb_put failures during sync... - while (!d->transaction.validateNamedDatabases()) { - Warning() << "Opened an invalid transaction!!!!!!"; - d->transaction = std::move(storage().createTransaction(Storage::ReadWrite, [](const Sink::Storage::Error &error) { - Warning() << error.message; - })); + if (d->storage.exists()) { + while (!d->transaction.validateNamedDatabases()) { + Warning() << "Opened an invalid transaction!!!!!!"; + d->transaction = std::move(storage().createTransaction(Storage::ReadWrite, [](const Sink::Storage::Error &error) { + Warning() << error.message; + })); + } } } diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index 90f046b..78a4b94 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp @@ -207,6 +207,11 @@ Storage::Transaction QueryWorker::getTransaction() Sink::Storage::Transaction transaction; { Sink::Storage storage(Sink::storageLocation(), mResourceInstanceIdentifier); + if (!storage.exists()) { + //This is not an error if the resource wasn't started before + Log() << "Store doesn't exist: " << mResourceInstanceIdentifier; + return Sink::Storage::Transaction(); + } storage.setDefaultErrorHandler([](const Sink::Storage::Error &error) { Warning() << "Error during query: " << error.store << error.message; }); transaction = storage.createTransaction(Sink::Storage::ReadOnly); } diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index aeb4dd6..3687594 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp @@ -524,7 +524,13 @@ QList Storage::Transaction::getDatabaseNames() const list << QByteArray::fromRawData((char *)key.mv_data, key.mv_size); } } else { - Warning() << "Failed to get a value" << rc; + //Normal if we don't have any databases yet + if (rc == MDB_NOTFOUND) { + rc = 0; + } + if (rc) { + Warning() << "Failed to get a value" << rc; + } } } else { Warning() << "Failed to open db" << rc << QByteArray(mdb_strerror(rc)); -- cgit v1.2.3