From 392d3c257c39ed391b2dfcde3b9a629ca251ee94 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 13 Nov 2019 11:12:32 +0100 Subject: [PATCH] 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 --- src/libsync/discovery.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 7d2b4e599..9ecb2a542 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -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)); } } });