diff options
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r-- | common/storage_common.cpp | 21 |
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 | ||
70 | void Storage::setMaxRevision(qint64 revision) | 70 | void 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 | |||
76 | void Storage::setMaxRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision) | ||
77 | { | ||
78 | transaction.write("__internal_maxRevision", QByteArray::number(revision)); | ||
73 | } | 79 | } |
74 | 80 | ||
75 | qint64 Storage::maxRevision() | 81 | qint64 Storage::maxRevision() |
76 | { | 82 | { |
83 | auto transaction = createTransaction(Akonadi2::Storage::ReadOnly); | ||
84 | return maxRevision(transaction); | ||
85 | } | ||
86 | |||
87 | qint64 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; |