summaryrefslogtreecommitdiffstats
path: root/common/synchronizerstore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/synchronizerstore.cpp')
-rw-r--r--common/synchronizerstore.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/synchronizerstore.cpp b/common/synchronizerstore.cpp
index fcb3ed0..a9da2fe 100644
--- a/common/synchronizerstore.cpp
+++ b/common/synchronizerstore.cpp
@@ -54,6 +54,10 @@ void SynchronizerStore::updateRemoteId(const QByteArray &bufferType, const QByte
54 54
55QByteArray SynchronizerStore::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId) 55QByteArray SynchronizerStore::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId)
56{ 56{
57 if (remoteId.isEmpty()) {
58 SinkWarning() << "Cannot resolve empty remote id for type: " << bufferType;
59 return QByteArray();
60 }
57 // Lookup local id for remote id, or insert a new pair otherwise 61 // Lookup local id for remote id, or insert a new pair otherwise
58 Index index("rid.mapping." + bufferType, mTransaction); 62 Index index("rid.mapping." + bufferType, mTransaction);
59 QByteArray sinkId = index.lookup(remoteId); 63 QByteArray sinkId = index.lookup(remoteId);
@@ -96,8 +100,33 @@ QByteArray SynchronizerStore::readValue(const QByteArray &key)
96 return value; 100 return value;
97} 101}
98 102
103QByteArray SynchronizerStore::readValue(const QByteArray &prefix, const QByteArray &key)
104{
105 return readValue(prefix + key);
106}
107
99void SynchronizerStore::writeValue(const QByteArray &key, const QByteArray &value) 108void SynchronizerStore::writeValue(const QByteArray &key, const QByteArray &value)
100{ 109{
101 mTransaction.openDatabase("values").write(key, value); 110 mTransaction.openDatabase("values").write(key, value);
102} 111}
103 112
113void SynchronizerStore::writeValue(const QByteArray &prefix, const QByteArray &key, const QByteArray &value)
114{
115 writeValue(prefix + key, value);
116}
117
118void SynchronizerStore::removeValue(const QByteArray &prefix, const QByteArray &key)
119{
120 mTransaction.openDatabase("values").remove(prefix + key, [&](const Sink::Storage::DataStore::Error &error) {
121 SinkWarning() << "Failed to remove the value: " << prefix + key << error;
122 });
123}
124
125void SynchronizerStore::removePrefix(const QByteArray &prefix)
126{
127 //FIXME remove all values matching prefix
128 // mTransaction.openDatabase("values").remove(prefix, [](const Sink::Storage::DataStore::Error &) {
129 // //Ignore errors because we may not find the value
130 // });
131}
132