Re-connect if Syncthing appears to be restarted
* This is now required after843f164d
which uses event IDs instead of time stamps and event IDs reset when Syncthing has been restarted. * It is likely a good idea to cleanly re-connect anyways. * This change re-introduces the previously uneffective and hence removed code (see8c74b240
). It fixes the code to effectively make sure a re-connect is continued once it has been started. So this change should fix the re-connect not working in certain cases.
This commit is contained in:
parent
c6a5b40a1d
commit
ae6b8712cb
|
@ -201,6 +201,9 @@ SyncthingConnection::Reply SyncthingConnection::handleReply(QNetworkReply *reply
|
|||
cerr << std::string_view(data.response.data(), static_cast<std::string_view::size_type>(data.response.size()));
|
||||
}
|
||||
}
|
||||
if (handleAborting && m_abortingToReconnect) {
|
||||
handleAdditionalRequestCanceled();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -1764,11 +1767,12 @@ bool SyncthingConnection::readEventsFromJsonArray(const QJsonArray &events, quin
|
|||
const auto eventId = static_cast<quint64>(std::max(eventIdValue.toDouble(), 0.0));
|
||||
if (eventIdValue.isDouble()) {
|
||||
if (eventId < lastId) {
|
||||
// re-connect if the event ID decreases as this indicates something weird on the other end happened
|
||||
// re-connect if the event ID decreases as this indicates Syncthing has been restarted
|
||||
// note: The Syncthing docs say "A unique ID for this event on the events API. It always increases by 1: the
|
||||
// first event generated has id 1, the next has id 2 etc.".
|
||||
if (loggingFlags() & SyncthingConnectionLoggingFlags::ApiCalls) {
|
||||
std::cerr << Phrases::Info << "Re-connecting as event ID is decreasing (" << eventId << " < " << lastId << ')' << Phrases::End;
|
||||
std::cerr << Phrases::Info << "Re-connecting as event ID is decreasing (" << eventId << " < " << lastId
|
||||
<< "), Syncthing has likely been restarted" << Phrases::End;
|
||||
}
|
||||
reconnect();
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue