Skip to content

Commit

Permalink
Tread a 502 as SoftError and retry the sync
Browse files Browse the repository at this point in the history
Fixes: #8811
  • Loading branch information
TheOneRing authored and dragotin committed Aug 10, 2021
1 parent ebde953 commit 81f0bbe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/8811
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Retry sync on `502 Bad Gateway`

We now treat a `502 Bad Gateway` as an less severer error and directly initialise a retry.

https://github.com/owncloud/client/issues/8811
33 changes: 17 additions & 16 deletions src/libsync/owncloudpropagator_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,23 @@ inline SyncFileItem::Status classifyError(QNetworkReply::NetworkError nerror,
return SyncFileItem::FatalError;
}

if (httpCode == 503) {
switch (httpCode) {
case 423:
// "Locked"
// Should be temporary.
Q_FALLTHROUGH();
case 502:
// "Bad Gateway"
// Should be temporary.
if (anotherSyncNeeded != nullptr) {
*anotherSyncNeeded = true;
}
Q_FALLTHROUGH();
case 412:
// "Precondition Failed"
// Happens when the e-tag has changed
return SyncFileItem::SoftError;
case 503: {
// When the server is in maintenance mode, we want to exit the sync immediatly
// so that we do not flood the server with many requests
// BUG: This relies on a translated string and is thus unreliable.
Expand All @@ -67,22 +83,7 @@ inline SyncFileItem::Status classifyError(QNetworkReply::NetworkError nerror,
&& !errorBody.contains("Storage is temporarily not available");
return probablyMaintenance ? SyncFileItem::FatalError : SyncFileItem::NormalError;
}

if (httpCode == 412) {
// "Precondition Failed"
// Happens when the e-tag has changed
return SyncFileItem::SoftError;
}

if (httpCode == 423) {
// "Locked"
// Should be temporary.
if (anotherSyncNeeded) {
*anotherSyncNeeded = true;
}
return SyncFileItem::SoftError;
}

return SyncFileItem::NormalError;
}
}

0 comments on commit 81f0bbe

Please sign in to comment.