diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-15 23:03:27 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-15 23:03:27 +0100 |
commit | e8b2898efcd2225adc7b14329cc246d9b29f1fa6 (patch) | |
tree | a8521217f55e7464a7b170a0f3cb58f3aa00fdd2 /common/storage_lmdb.cpp | |
parent | 8ba8ff25c86a73045ab86238fdefc9486fa3738b (diff) | |
download | sink-e8b2898efcd2225adc7b14329cc246d9b29f1fa6.tar.gz sink-e8b2898efcd2225adc7b14329cc246d9b29f1fa6.zip |
Fixed messageqeue and storage. Empty scan is not an error.
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r-- | common/storage_lmdb.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index ae2be23..2dc4817 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp | |||
@@ -218,7 +218,6 @@ bool Storage::write(void const *keyPtr, size_t keySize, void const *valuePtr, si | |||
218 | 218 | ||
219 | const bool implicitTransaction = !d->transaction || d->readTransaction; | 219 | const bool implicitTransaction = !d->transaction || d->readTransaction; |
220 | if (implicitTransaction) { | 220 | if (implicitTransaction) { |
221 | // TODO: if this fails, still try the write below? | ||
222 | if (!startTransaction()) { | 221 | if (!startTransaction()) { |
223 | return false; | 222 | return false; |
224 | } | 223 | } |
@@ -292,7 +291,6 @@ void Storage::scan(const char *keyData, uint keySize, | |||
292 | 291 | ||
293 | const bool implicitTransaction = !d->transaction; | 292 | const bool implicitTransaction = !d->transaction; |
294 | if (implicitTransaction) { | 293 | if (implicitTransaction) { |
295 | // TODO: if this fails, still try the write below? | ||
296 | if (!startTransaction(ReadOnly)) { | 294 | if (!startTransaction(ReadOnly)) { |
297 | Error error(d->name.toStdString(), -2, "Could not start transaction"); | 295 | Error error(d->name.toStdString(), -2, "Could not start transaction"); |
298 | errorHandler(error); | 296 | errorHandler(error); |
@@ -308,19 +306,18 @@ void Storage::scan(const char *keyData, uint keySize, | |||
308 | } | 306 | } |
309 | 307 | ||
310 | if (!keyData || keySize == 0) { | 308 | if (!keyData || keySize == 0) { |
311 | bool gotResult = false; | 309 | if ((rc = mdb_cursor_get(cursor, &key, &data, MDB_FIRST)) == 0) { |
312 | if ((rc = mdb_cursor_get(cursor, &key, &data, MDB_FIRST)) == 0 && | 310 | if (resultHandler(key.mv_data, key.mv_size, data.mv_data, data.mv_size)) { |
313 | resultHandler(key.mv_data, key.mv_size, data.mv_data, data.mv_size)) { | 311 | while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { |
314 | while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { | 312 | if (!resultHandler(key.mv_data, key.mv_size, data.mv_data, data.mv_size)) { |
315 | gotResult = true; | 313 | break; |
316 | if (!resultHandler(key.mv_data, key.mv_size, data.mv_data, data.mv_size)) { | 314 | } |
317 | break; | ||
318 | } | 315 | } |
319 | } | 316 | } |
320 | } | 317 | } |
321 | 318 | ||
322 | //We never find the last value, but ensure we got at least one. | 319 | //We never find the last value, but ensure we got at least one. |
323 | if (gotResult && rc == MDB_NOTFOUND) { | 320 | if (rc == MDB_NOTFOUND) { |
324 | rc = 0; | 321 | rc = 0; |
325 | } | 322 | } |
326 | } else { | 323 | } else { |
@@ -400,8 +397,11 @@ qint64 Storage::diskUsage() const | |||
400 | void Storage::removeFromDisk() const | 397 | void Storage::removeFromDisk() const |
401 | { | 398 | { |
402 | QDir dir(d->storageRoot + '/' + d->name); | 399 | QDir dir(d->storageRoot + '/' + d->name); |
403 | dir.remove("data.mdb"); | 400 | // dir.remove("data.mdb"); |
404 | dir.remove("lock.mdb"); | 401 | // dir.remove("lock.mdb"); |
402 | if (!dir.removeRecursively()) { | ||
403 | qWarning() << "Failed to remove directory" << d->storageRoot << d->name; | ||
404 | } | ||
405 | } | 405 | } |
406 | 406 | ||
407 | } // namespace Akonadi2 | 407 | } // namespace Akonadi2 |