}
}
+void PropagateUploadFileCommon::commonErrorHandling(AbstractNetworkJob *job)
+{
+ QByteArray replyContent;
+ QString errorString = job->errorStringParsingBody(&replyContent);
+ qCDebug(lcPropagateUpload) << replyContent; // display the XML error in the debug
+
+ if (_item->_httpErrorCode == 412) {
+ // Precondition Failed: Either an etag or a checksum mismatch.
+
+ // 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.
+ propagator()->_journal->avoidReadFromDbOnNextSync(_item->_file);
+ propagator()->_anotherSyncNeeded = true;
+ }
+
+ // Ensure errors that should eventually reset the chunked upload are tracked.
+ checkResettingErrors();
+
+ SyncFileItem::Status status = classifyError(job->reply()->error(), _item->_httpErrorCode,
+ &propagator()->_anotherSyncNeeded);
+ abortWithError(status, errorString);
+}
+
void PropagateUploadFileCommon::slotJobDestroyed(QObject *job)
{
_jobs.erase(std::remove(_jobs.begin(), _jobs.end(), job), _jobs.end());
*/
void checkResettingErrors();
+ /**
+ * Error handling functionality that is shared between jobs.
+ */
+ void commonErrorHandling(AbstractNetworkJob *job);
+
// Bases headers that need to be sent with every chunk
QMap<QByteArray, QByteArray> headers();
};
if (err != QNetworkReply::NoError) {
_item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- QByteArray replyContent;
- QString errorString = job->errorStringParsingBody(&replyContent);
- qCDebug(lcPropagateUpload) << replyContent; // display the XML error in the debug
-
- // Ensure errors that should eventually reset the chunked upload are tracked.
- checkResettingErrors();
-
- SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
- &propagator()->_anotherSyncNeeded);
- abortWithError(status, errorString);
+ commonErrorHandling(job);
return;
}
_item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (err != QNetworkReply::NoError) {
- if (_item->_httpErrorCode == 412) {
- // Precondition Failed: Either an etag or a checksum mismatch.
-
- // 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.
- propagator()->_journal->avoidReadFromDbOnNextSync(_item->_file);
- propagator()->_anotherSyncNeeded = true;
- }
-
- // Ensure errors that should eventually reset the chunked upload are tracked.
- checkResettingErrors();
-
- SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
- &propagator()->_anotherSyncNeeded);
- abortWithError(status, job->errorStringParsingBody());
+ commonErrorHandling(job);
return;
}
if (_item->_httpErrorCode != 201 && _item->_httpErrorCode != 204) {
"It is restored and your edit is in the conflict file."))) {
return;
}
- QByteArray replyContent;
- QString errorString = job->errorStringParsingBody(&replyContent);
- qCDebug(lcPropagateUpload) << replyContent; // display the XML error in the debug
-
- if (_item->_httpErrorCode == 412) {
- // Precondition Failed: Either an etag or a checksum mismatch.
-
- // 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.
- propagator()->_journal->avoidReadFromDbOnNextSync(_item->_file);
- propagator()->_anotherSyncNeeded = true;
- }
-
- // Ensure errors that should eventually reset the chunked upload are tracked.
- checkResettingErrors();
-
- SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
- &propagator()->_anotherSyncNeeded);
- abortWithError(status, errorString);
+ commonErrorHandling(job);
return;
}