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:
Olivier Goffart 2015-02-26 15:52:07 +01:00
Родитель c8167b77c9
Коммит d8b6e00fe7
6 изменённых файлов: 35 добавлений и 6 удалений

Просмотреть файл

@ -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.