Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Limit the number of people.connections.li…
Browse files Browse the repository at this point in the history
…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 5499f75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -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>(
Expand All @@ -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;
Expand Down
Expand Up @@ -173,6 +173,7 @@ class GoogleTwoWayContactSyncAdaptor : public GoogleDataTypeSyncAdaptor

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

Expand Down

0 comments on commit 5499f75

Please sign in to comment.