summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2019-08-08 17:31:32 -0500
committerAdam Ierymenko <adam.ierymenko@gmail.com>2019-08-08 17:31:32 -0500
commit730305ecc7961752d10dae2bcb195e4de1c45464 (patch)
tree867759bcb469bcd8eba40cbbb3fc6703de1950a5
parentf8f2432ece59fbc0913d011423ecc1e369924bcd (diff)
downloadinfinitytier-730305ecc7961752d10dae2bcb195e4de1c45464.tar.gz
infinitytier-730305ecc7961752d10dae2bcb195e4de1c45464.zip
One more sync fix.
-rw-r--r--controller/DBMirrorSet.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/controller/DBMirrorSet.cpp b/controller/DBMirrorSet.cpp
index c1be6b9c..c3cd7841 100644
--- a/controller/DBMirrorSet.cpp
+++ b/controller/DBMirrorSet.cpp
@@ -50,27 +50,31 @@ DBMirrorSet::DBMirrorSet(DB::ChangeListener *listener) :
for(auto db=dbs.begin();db!=dbs.end();++db) {
(*db)->each([this,&dbs,&db](uint64_t networkId,const nlohmann::json &network,uint64_t memberId,const nlohmann::json &member) {
- if (memberId == 0) {
- for(auto db2=dbs.begin();db2!=dbs.end();++db2) {
- if (db->get() != db2->get()) {
- nlohmann::json nw2;
- if ((!(*db2)->get(networkId,nw2))||(OSUtils::jsonInt(nw2["revision"],0) < OSUtils::jsonInt(network["revision"],0))) {
- nw2 = network;
- (*db2)->save(nw2,false);
+ try {
+ if (network.is_object()) {
+ if (memberId == 0) {
+ for(auto db2=dbs.begin();db2!=dbs.end();++db2) {
+ if (db->get() != db2->get()) {
+ nlohmann::json nw2;
+ if ((!(*db2)->get(networkId,nw2))||((nw2.is_object())&&(OSUtils::jsonInt(nw2["revision"],0) < OSUtils::jsonInt(network["revision"],0)))) {
+ nw2 = network;
+ (*db2)->save(nw2,false);
+ }
+ }
}
- }
- }
- } else {
- for(auto db2=dbs.begin();db2!=dbs.end();++db2) {
- if (db->get() != db2->get()) {
- nlohmann::json nw2,m2;
- if ((!(*db2)->get(networkId,nw2,memberId,m2))||(OSUtils::jsonInt(nw2["revision"],0) < OSUtils::jsonInt(network["revision"],0))) {
- m2 = member;
- (*db2)->save(m2,false);
+ } else if (member.is_object()) {
+ for(auto db2=dbs.begin();db2!=dbs.end();++db2) {
+ if (db->get() != db2->get()) {
+ nlohmann::json nw2,m2;
+ if ((!(*db2)->get(networkId,nw2,memberId,m2))||((m2.is_object())&&(OSUtils::jsonInt(m2["revision"],0) < OSUtils::jsonInt(member["revision"],0)))) {
+ m2 = member;
+ (*db2)->save(m2,false);
+ }
+ }
}
}
}
- }
+ } catch ( ... ) {} // skip entries that generate JSON errors
});
}
}