Skip to content
Permalink
Browse files
[buteo-sync-plugins-social] Limit the number of people.connections.li…
…st() queries.

If a retry fails, the next one will be a clean sync, and if that fails
there's no need to make another request after that.
  • Loading branch information
blammit committed Mar 10, 2021
1 parent 88beda1 commit 5499f75ff4790bd528b24ce0764b922ffbfadfba
Showing with 4 additions and 1 deletion.
  1. +3 −1 src/google/google-contacts/googletwowaycontactsyncadaptor.cpp
  2. +1 −0 src/google/google-contacts/googletwowaycontactsyncadaptor.h
@@ -419,7 +419,8 @@ void GoogleTwoWayContactSyncAdaptor::contactsFinishedHandler()

if (reply->error() == QNetworkReply::ProtocolInvalidOperationError) {
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 400) {
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 400
&& !m_retriedConnectionsList) {
SOCIALD_LOG_INFO("Will request new sync token, got error from server:"
<< reply->readAll());
DataRequestType requestType = static_cast<DataRequestType>(
@@ -428,6 +429,7 @@ void GoogleTwoWayContactSyncAdaptor::contactsFinishedHandler()
reply->property("contactChangeNotifier").toInt());
m_connectionsListParams.requestSyncToken = true;
m_connectionsListParams.syncToken.clear();
m_retriedConnectionsList = true;
requestData(requestType, contactChangeNotifier);
decrementSemaphore(m_accountId);
return;
@@ -173,6 +173,7 @@ class GoogleTwoWayContactSyncAdaptor : public GoogleDataTypeSyncAdaptor

int m_accountId = 0;
int m_apiRequestsRemaining = 0;
bool m_retriedConnectionsList = false;
bool m_allowFinalCleanup = false;
};

0 comments on commit 5499f75

Please sign in to comment.