Skip to content

Commit b0663c1

Browse files
committed
Tread a 502 as SoftError and retry the sync
Fixes: #8811
1 parent f2c04e1 commit b0663c1

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

changelog/unreleased/8811

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: Retry sync on `502 Bad Gateway`
2+
3+
We now treat a `502 Bad Gateway` as an less severer error and directly initialise a retry.
4+
5+
https://github.com/owncloud/client/issues/8811

src/libsync/owncloudpropagator_p.h

+17-16
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,23 @@ inline SyncFileItem::Status classifyError(QNetworkReply::NetworkError nerror,
5656
return SyncFileItem::FatalError;
5757
}
5858

59-
if (httpCode == 503) {
59+
switch (httpCode) {
60+
case 423:
61+
// "Locked"
62+
// Should be temporary.
63+
Q_FALLTHROUGH();
64+
case 502:
65+
// "Bad Gateway"
66+
// Should be temporary.
67+
if (anotherSyncNeeded != nullptr) {
68+
*anotherSyncNeeded = true;
69+
}
70+
Q_FALLTHROUGH();
71+
case 412:
72+
// "Precondition Failed"
73+
// Happens when the e-tag has changed
74+
return SyncFileItem::SoftError;
75+
case 503: {
6076
// When the server is in maintenance mode, we want to exit the sync immediatly
6177
// so that we do not flood the server with many requests
6278
// BUG: This relies on a translated string and is thus unreliable.
@@ -67,22 +83,7 @@ inline SyncFileItem::Status classifyError(QNetworkReply::NetworkError nerror,
6783
&& !errorBody.contains("Storage is temporarily not available");
6884
return probablyMaintenance ? SyncFileItem::FatalError : SyncFileItem::NormalError;
6985
}
70-
71-
if (httpCode == 412) {
72-
// "Precondition Failed"
73-
// Happens when the e-tag has changed
74-
return SyncFileItem::SoftError;
75-
}
76-
77-
if (httpCode == 423) {
78-
// "Locked"
79-
// Should be temporary.
80-
if (anotherSyncNeeded) {
81-
*anotherSyncNeeded = true;
82-
}
83-
return SyncFileItem::SoftError;
8486
}
85-
8687
return SyncFileItem::NormalError;
8788
}
8889
}

0 commit comments

Comments
 (0)