mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 21:46:03 +03:00
Propagator: Let network propagator job understand a new header OC-ErrorString
This allows the server to send a readable error string in many cases
This commit is contained in:
parent
c8167b77c9
commit
d8b6e00fe7
6 changed files with 35 additions and 6 deletions
|
@ -263,6 +263,17 @@ void GETFileJob::slotTimeout()
|
|||
reply()->abort();
|
||||
}
|
||||
|
||||
QString GETFileJob::errorString() const
|
||||
{
|
||||
if (!_errorString.isEmpty()) {
|
||||
return _errorString;
|
||||
} else if (reply()->hasRawHeader("OC-ErrorString")) {
|
||||
return reply()->rawHeader("OC-ErrorString");
|
||||
} else {
|
||||
return reply()->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void PropagateDownloadFileQNAM::start()
|
||||
{
|
||||
if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
|
||||
|
|
|
@ -77,9 +77,7 @@ public:
|
|||
void giveBandwidthQuota(qint64 q);
|
||||
qint64 currentDownloadPosition();
|
||||
|
||||
QString errorString() {
|
||||
return _errorString.isEmpty() ? reply()->errorString() : _errorString;
|
||||
}
|
||||
QString errorString() const;
|
||||
|
||||
SyncFileItem::Status errorStatus() { return _errorStatus; }
|
||||
|
||||
|
|
|
@ -38,7 +38,13 @@ void DeleteJob::start()
|
|||
|
||||
QString DeleteJob::errorString()
|
||||
{
|
||||
return _timedout ? tr("Connection timed out") : reply()->errorString();
|
||||
if (_timedout) {
|
||||
return tr("Connection timed out");
|
||||
} else if (reply()->hasRawHeader("OC-ErrorString")) {
|
||||
return reply()->rawHeader("OC-ErrorString");
|
||||
} else {
|
||||
return reply()->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
bool DeleteJob::finished()
|
||||
|
|
|
@ -58,7 +58,11 @@ void PropagateRemoteMkdir::slotMkcolJobFinished()
|
|||
// This happens when the directory already exist. Nothing to do.
|
||||
} else if (err != QNetworkReply::NoError) {
|
||||
SyncFileItem::Status status = classifyError(err, _item._httpErrorCode);
|
||||
done(status, _job->reply()->errorString());
|
||||
auto errorString = _job->reply()->errorString();
|
||||
if (_job->reply()->hasRawHeader("OC-ErrorString")) {
|
||||
errorString = _job->reply()->rawHeader("OC-ErrorString");
|
||||
}
|
||||
done(status, errorString);
|
||||
return;
|
||||
} else if (_item._httpErrorCode != 201) {
|
||||
// Normaly we expect "201 Created"
|
||||
|
|
|
@ -43,7 +43,13 @@ void MoveJob::start()
|
|||
|
||||
QString MoveJob::errorString()
|
||||
{
|
||||
return _timedout ? tr("Connection timed out") : reply()->errorString();
|
||||
if (_timedout) {
|
||||
return tr("Connection timed out");
|
||||
} else if (reply()->hasRawHeader("OC-ErrorString")) {
|
||||
return reply()->rawHeader("OC-ErrorString");
|
||||
} else {
|
||||
return reply()->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
bool MoveJob::finished()
|
||||
|
|
|
@ -475,6 +475,10 @@ void PropagateUploadFileQNAM::slotPutFinished()
|
|||
errorString += QLatin1String(" (") + rx.cap(1) + QLatin1Char(')');
|
||||
}
|
||||
|
||||
if (job->reply()->hasRawHeader("OC-ErrorString")) {
|
||||
errorString = job->reply()->rawHeader("OC-ErrorString");
|
||||
}
|
||||
|
||||
if (_item._httpErrorCode == 412) {
|
||||
// Precondition Failed: Maybe the bad etag is in the database, we need to clear the
|
||||
// parent folder etag so we won't read from DB next sync.
|
||||
|
|
Loading…
Reference in a new issue