Skip to content

Commit 4cbfdb2

Browse files
committed
Discovery: Allow more HTTP error code to be treated as ignored dir
The original code from csync was stopping at any error. But we have been whitelisting soeme http error code one by one to ignore the directory instead of aborting the sync. However, as there are more requests to continue the sync in case of error, just ignore most HTTP errors Issue #7586
1 parent 1d757af commit 4cbfdb2

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

src/libsync/discovery.cpp

+9-19
Original file line numberDiff line numberDiff line change
@@ -1405,34 +1405,24 @@ DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery()
14051405
if (_localQueryDone)
14061406
this->process();
14071407
} else {
1408-
auto fatalError = [&] {
1409-
emit _discoveryData->fatalError(tr("Server replied with an error while reading directory '%1' : %2")
1410-
.arg(_currentFolder._server, results.error().message));
1411-
};
1412-
auto ignoreOrFatal = [&] {
1413-
if (_dirItem) {
1414-
_dirItem->_instruction = CSYNC_INSTRUCTION_IGNORE;
1415-
_dirItem->_errorString = results.error().message;
1416-
emit this->finished();
1417-
} else {
1418-
// Fatal for the root job since it has no SyncFileItem
1419-
fatalError();
1420-
}
1421-
};
1422-
14231408
auto code = results.error().code;
14241409
qCWarning(lcDisco) << "Server error in directory" << _currentFolder._server << code;
1425-
if (code == 403 || code == 404 || code == 500 || code == 503) {
1410+
if (_dirItem && code >= 403) {
1411+
// In case of an HTTP error, we ignore that directory
14261412
// 403 Forbidden can be sent by the server if the file firewall is active.
14271413
// A file or directory should be ignored and sync must continue. See #3490
14281414
// The server usually replies with the custom "503 Storage not available"
14291415
// if some path is temporarily unavailable. But in some cases a standard 503
14301416
// is returned too. Thus we can't distinguish the two and will treat any
14311417
// 503 as request to ignore the folder. See #3113 #2884.
1432-
// Similarly, the server might also return 404 or 500 in case of bugs. #7199
1433-
ignoreOrFatal();
1418+
// Similarly, the server might also return 404 or 50x in case of bugs. #7199 #7586
1419+
_dirItem->_instruction = CSYNC_INSTRUCTION_IGNORE;
1420+
_dirItem->_errorString = results.error().message;
1421+
emit this->finished();
14341422
} else {
1435-
fatalError();
1423+
// Fatal for the root job since it has no SyncFileItem, or for the network errors
1424+
emit _discoveryData->fatalError(tr("Server replied with an error while reading directory '%1' : %2")
1425+
.arg(_currentFolder._server, results.error().message));
14361426
}
14371427
}
14381428
});

0 commit comments

Comments
 (0)