Propagator: Introduce custom property to make error soft
authorMarkus Goetz <markus@woboq.com>
Tue, 17 Mar 2015 22:31:30 +0000 (23:31 +0100)
committerMarkus Goetz <markus@woboq.com>
Tue, 17 Mar 2015 22:31:30 +0000 (23:31 +0100)
This can be set by a custom credential QNAM.

src/libsync/propagatedownload.cpp
src/libsync/propagatedownload.h

index 9084d97d3c8e136c4798912f03cb8502259f3c88..85b8fab71c97704206c43d04c57e4378fbd654e0 100644 (file)
@@ -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);
         }
index ad71f743ae61a2996836b8565ebef80bcf269fb7..47c60702ae062870bf61fc83e63f0b134728a171 100644 (file)
@@ -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;