diff options
author | Christian Kamm <mail@ckamm.de> | 2019-04-10 12:07:15 +0300 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-15 12:58:48 +0300 |
commit | c50f041c5b7a391a8b5a4f232c658a96476f2ae5 (patch) | |
tree | 7d79108ce487c52d5f0bea7882151c85021507a4 /src/libsync/discovery.cpp | |
parent | 7b96321df2b2aba053d781b60cb7a78b8c803787 (diff) |
Discovery: 403 and 503 on root cause error
Previously these result codes during remote discovery of the sync root
would not cause an error and the discovery would get stuck.
Also extends RemoteDiscovery tests to check for errors on the root item.
Diffstat (limited to 'src/libsync/discovery.cpp')
-rw-r--r-- | src/libsync/discovery.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 5a838ad51..6a3d04f36 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1342,31 +1342,37 @@ DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery() if (_localQueryDone) process(); } else { - if (results.error().code == 403) { - // 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 - qCWarning(lcDisco, "Directory access Forbidden (File Firewall?)"); + 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(); - return; + } else { + // Fatal for the root job since it has no SyncFileItem + fatalError(); } + }; + + if (results.error().code == 403) { + // 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 + qCWarning(lcDisco, "Directory access Forbidden (File Firewall?)"); + ignoreOrFatal(); } else if (results.error().code == 503) { // 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. qCWarning(lcDisco(), "Storage was not available!"); - if (_dirItem) { - _dirItem->_instruction = CSYNC_INSTRUCTION_IGNORE; - _dirItem->_errorString = results.error().message; - emit finished(); - return; - } + ignoreOrFatal(); + } else { + qCWarning(lcDisco) << "Server error in directory" << _currentFolder._server << results.error().message; + fatalError(); } - emit _discoveryData->fatalError(tr("Server replied with an error while reading directory '%1' : %2") - .arg(_currentFolder._server, results.error().message)); } }); connect(serverJob, &DiscoverySingleDirectoryJob::firstDirectoryPermissions, this, |