summaryrefslogtreecommitdiffstats
path: root/common/storage_common.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-10 23:32:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-10 23:32:31 +0200
commit4f393198d022815c66b10871c7e5efe45a0bf462 (patch)
treefe5e87503d4298df78d9b1110388798de493f00b /common/storage_common.cpp
parent13cd7cff06f1e4e51fb2a5d16b57662292c80b77 (diff)
downloadsink-4f393198d022815c66b10871c7e5efe45a0bf462.tar.gz
sink-4f393198d022815c66b10871c7e5efe45a0bf462.zip
Ported messagequeue to new API
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r--common/storage_common.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp
index 65f6e57..8006a8e 100644
--- a/common/storage_common.cpp
+++ b/common/storage_common.cpp
@@ -69,18 +69,31 @@ bool Storage::write(const QByteArray &sKey, const QByteArray &sValue, const std:
69 69
70void Storage::setMaxRevision(qint64 revision) 70void Storage::setMaxRevision(qint64 revision)
71{ 71{
72 write("__internal_maxRevision", QByteArray::number(revision)); 72 auto transaction = createTransaction(Akonadi2::Storage::ReadWrite);
73 setMaxRevision(transaction, revision);
74}
75
76void Storage::setMaxRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision)
77{
78 transaction.write("__internal_maxRevision", QByteArray::number(revision));
73} 79}
74 80
75qint64 Storage::maxRevision() 81qint64 Storage::maxRevision()
76{ 82{
83 auto transaction = createTransaction(Akonadi2::Storage::ReadOnly);
84 return maxRevision(transaction);
85}
86
87qint64 Storage::maxRevision(const Akonadi2::Storage::Transaction &transaction)
88{
77 qint64 r = 0; 89 qint64 r = 0;
78 scan("__internal_maxRevision", [&](const QByteArray &revision) -> bool { 90 transaction.scan("__internal_maxRevision", [&](const QByteArray &, const QByteArray &revision) -> bool {
79 r = revision.toLongLong(); 91 r = revision.toLongLong();
80 return false; 92 return false;
81 }, [this](const Error &error){ 93 }, [](const Error &error){
82 if (error.code != ErrorCodes::NotFound) { 94 if (error.code != ErrorCodes::NotFound) {
83 defaultErrorHandler()(error); 95 //FIXME
96 // defaultErrorHandler()(error);
84 } 97 }
85 }); 98 });
86 return r; 99 return r;