Skip to content

Commit

Permalink
Discovery: Allow more HTTP error code to be treated as ignored dir
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ogoffart committed Nov 18, 2019
1 parent 1d757af commit 3a56839
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,34 +1405,24 @@ DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery()
if (_localQueryDone)
this->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 this->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 this->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));
}
}
});
Expand Down

0 comments on commit 3a56839

Please sign in to comment.