From 06a2f58c5121597b2f29c2e4780e3680689e8d1f Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 17 Mar 2015 23:31:30 +0100 Subject: [PATCH] Propagator: Introduce custom property to make error soft This can be set by a custom credential QNAM. --- src/libsync/propagatedownload.cpp | 12 ++++++++++++ src/libsync/propagatedownload.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 9084d97d3..85b8fab71 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -368,6 +368,7 @@ void PropagateDownloadFileQNAM::start() _job->start(); } +const char owncloudCustomSoftErrorStringC[] = "owncloud-custom-soft-error-string"; void PropagateDownloadFileQNAM::slotGetFinished() { _propagator->_activeJobs--; @@ -407,7 +408,18 @@ void PropagateDownloadFileQNAM::slotGetFinished() return; } + // This gives a custom QNAM (by the user of libowncloudsync) to abort() a QNetworkReply in its metaDataChanged() slot and + // set a custom error string to make this a soft error. In contrast to the default hard error this won't bring down + // the whole sync and allows for a custom error message. + QNetworkReply *reply = job->reply(); + if (err == QNetworkReply::OperationCanceledError && reply->property(owncloudCustomSoftErrorStringC).isValid()) { + job->setErrorString(reply->property(owncloudCustomSoftErrorStringC).toString()); + job->setErrorStatus(SyncFileItem::SoftError); + } + SyncFileItem::Status status = job->errorStatus(); + + if (status == SyncFileItem::NoStatus) { status = classifyError(err, _item._httpErrorCode); } diff --git a/src/libsync/propagatedownload.h b/src/libsync/propagatedownload.h index ad71f743a..47c60702a 100644 --- a/src/libsync/propagatedownload.h +++ b/src/libsync/propagatedownload.h @@ -78,8 +78,10 @@ public: qint64 currentDownloadPosition(); QString errorString() const; + void setErrorString(const QString& s) { _errorString = s; } SyncFileItem::Status errorStatus() { return _errorStatus; } + void setErrorStatus(const SyncFileItem::Status & s) { _errorStatus = s; } virtual void slotTimeout() Q_DECL_OVERRIDE; -- 2.30.2