Try really hard to make sync RPC finish
This commit is contained in:
@@ -241,8 +241,27 @@ void ConnectionLoader::doAutoConnect()
|
||||
syncTimer->deleteLater();
|
||||
// When sync is done, set the connection
|
||||
this->doRPCSetConnection(connection);
|
||||
}, [=](auto) {
|
||||
}, [=](auto) mutable {
|
||||
DEBUG("sync rpc error! server=" << config->server);
|
||||
// continually retry sync RPC until it succeeds
|
||||
// change server each time it fails
|
||||
bool failed = true;
|
||||
do {
|
||||
config->server = Settings::getRandomServer();
|
||||
auto connection = makeConnection(config);
|
||||
DEBUG("changed server to " << config->server);
|
||||
connection->doRPC("sync", "", [=](auto) mutable {
|
||||
DEBUG("sync success with server=" << config->server);
|
||||
failed = false;
|
||||
isSyncing->store(false);
|
||||
// Cancel the timer
|
||||
syncTimer->deleteLater();
|
||||
// When sync is done, set the connection
|
||||
this->doRPCSetConnection(connection);
|
||||
}, [=](auto) {
|
||||
DEBUG("sync failed with server=" << config->server << " . continuing sync loop" );
|
||||
});
|
||||
} while (failed);
|
||||
});
|
||||
|
||||
// While it is syncing, we'll show the status updates while it is alive.
|
||||
@@ -261,12 +280,11 @@ void ConnectionLoader::doAutoConnect()
|
||||
}
|
||||
},
|
||||
[=](QString err) {
|
||||
DEBUG("Sync error" << err);
|
||||
DEBUG("syncstatus error" << err);
|
||||
});
|
||||
} catch (const std::exception& e) {
|
||||
DEBUG("caught exception from syncstatus: " << e.what());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user