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
This commit is contained in:
Olivier Goffart 2019-11-13 11:12:32 +01:00 committed by Kevin Ottens
parent 43c7e32ee1
commit 392d3c257c
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2

View file

@ -1415,34 +1415,24 @@ DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery()
if (_localQueryDone)
process();
} else {
auto fatalError = [&] {
emit _discoveryData->fatalError(tr("Server replied with an error while reading directory '%1' : %2")
.arg(_currentFolder._server, results.error().message));
};
auto ignoreOrFatal = [&] {
if (_dirItem) {
_dirItem->_instruction = CSYNC_INSTRUCTION_IGNORE;
_dirItem->_errorString = results.error().message;
emit finished();
} else {
// Fatal for the root job since it has no SyncFileItem
fatalError();
}
};
auto code = results.error().code;
qCWarning(lcDisco) << "Server error in directory" << _currentFolder._server << code;
if (code == 403 || code == 404 || code == 500 || code == 503) {
if (_dirItem && code >= 403) {
// In case of an HTTP error, we ignore that directory
// 403 Forbidden can be sent by the server if the file firewall is active.
// A file or directory should be ignored and sync must continue. See #3490
// The server usually replies with the custom "503 Storage not available"
// if some path is temporarily unavailable. But in some cases a standard 503
// is returned too. Thus we can't distinguish the two and will treat any
// 503 as request to ignore the folder. See #3113 #2884.
// Similarly, the server might also return 404 or 500 in case of bugs. #7199
ignoreOrFatal();
// Similarly, the server might also return 404 or 50x in case of bugs. #7199 #7586
_dirItem->_instruction = CSYNC_INSTRUCTION_IGNORE;
_dirItem->_errorString = results.error().message;
emit finished();
} else {
fatalError();
// Fatal for the root job since it has no SyncFileItem, or for the network errors
emit _discoveryData->fatalError(tr("Server replied with an error while reading directory '%1' : %2")
.arg(_currentFolder._server, results.error().message));
}
}
});