diff options
Diffstat (limited to 'common/synchronizerstore.cpp')
-rw-r--r-- | common/synchronizerstore.cpp | 29 |
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 | ||
55 | QByteArray SynchronizerStore::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId) | 55 | QByteArray 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 | ||
103 | QByteArray SynchronizerStore::readValue(const QByteArray &prefix, const QByteArray &key) | ||
104 | { | ||
105 | return readValue(prefix + key); | ||
106 | } | ||
107 | |||
99 | void SynchronizerStore::writeValue(const QByteArray &key, const QByteArray &value) | 108 | void 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 | ||
113 | void SynchronizerStore::writeValue(const QByteArray &prefix, const QByteArray &key, const QByteArray &value) | ||
114 | { | ||
115 | writeValue(prefix + key, value); | ||
116 | } | ||
117 | |||
118 | void 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 | |||
125 | void 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 | |||