From 818b5854ce614f6ae1c43c99adb443ae5c61e147 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 3 Aug 2016 17:43:03 +0200 Subject: [PATCH] Chunking-NG: Qt4 compile --- src/libsync/owncloudpropagator.h | 3 ++- src/libsync/propagateupload.h | 1 + src/libsync/propagateuploadng.cpp | 30 ++++++++++++++++-------------- src/libsync/propagateuploadv1.cpp | 3 +-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index b571e64a6..1b4246c3b 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -379,10 +379,11 @@ private: #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // access to signals which are protected in Qt4 friend class PropagateDownloadFile; - friend class PropagateUploadFile; friend class PropagateLocalMkdir; friend class PropagateLocalRename; friend class PropagateRemoteMove; + friend class PropagateUploadFileV1; + friend class PropagateUploadFileNG; #endif }; diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index 83b1fea65..1cde85196 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -307,6 +307,7 @@ private: private slots: void slotPropfindFinished(); void slotPropfindFinishedWithError(); + void slotPropfindIterate(const QString &name, const QMap &properties); void slotMkColFinished(QNetworkReply::NetworkError); void slotPutFinished(); void slotMoveJobFinished(); diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 95b41fa20..889156135 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -73,8 +73,6 @@ QUrl PropagateUploadFileNG::chunkUrl(int chunk) */ - - void PropagateUploadFileNG::doStartUpload() { _duration.start(); @@ -92,17 +90,8 @@ void PropagateUploadFileNG::doStartUpload() this, SLOT(slotPropfindFinishedWithError())); connect(job, SIGNAL(destroyed(QObject*)), this, SLOT(slotJobDestroyed(QObject*))); //TODO: port to Qt4 - connect(job, &LsColJob::directoryListingIterated, - [this, url](const QString &name, const QMap &properties) mutable { - if (name == url.path()) { - return; // skip the info about the path itself - } - bool ok = false; - auto chunkId = name.midRef(name.lastIndexOf('/')+1).toUInt(&ok); - if (ok) { - this->_serverChunks[chunkId] = properties["getcontentlength"].toULongLong(); - } - }); + connect(job, SIGNAL(directoryListingIterated(QString,QMap)), + this, SLOT(slotPropfindIterate(QString,QMap))); job->start(); return; } @@ -110,6 +99,18 @@ void PropagateUploadFileNG::doStartUpload() startNewUpload(); } +void PropagateUploadFileNG::slotPropfindIterate(const QString &name, const QMap &properties) +{ + if (name == chunkUrl().path()) { + return; // skip the info about the path itself + } + bool ok = false; + auto chunkId = name.mid(name.lastIndexOf('/')+1).toUInt(&ok); + if (ok) { + this->_serverChunks[chunkId] = properties["getcontentlength"].toULongLong(); + } +} + void PropagateUploadFileNG::slotPropfindFinished() { auto job = qobject_cast(sender()); @@ -122,6 +123,7 @@ void PropagateUploadFileNG::slotPropfindFinished() _sent += _serverChunks[_currentChunk]; ++_currentChunk; } + qDebug() << "Resuming "<< _item->_file << " from chunk " << _currentChunk << "; sent ="<< _sent; startNextChunk(); } @@ -272,7 +274,7 @@ void PropagateUploadFileNG::slotPutFinished() QNetworkReply::NetworkError err = job->reply()->error(); #if QT_VERSION < QT_VERSION_CHECK(5, 4, 2) - if (err == QNetworkReply::OperationCanceledError && job->reply()->property(owncloudShouldSoftCancelPropertyName).isValid()) { + if (err == QNetworkReply::OperationCanceledError && job->reply()->property("owncloud-should-soft-cancel").isValid()) { // Abort the job and try again later. // This works around a bug in QNAM wich might reuse a non-empty buffer for the next request. qDebug() << "Forcing job abort on HTTP connection reset with Qt < 5.4.2."; diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index c126164b3..dd075fa77 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -183,8 +183,7 @@ void PropagateUploadFileV1::slotPutFinished() QNetworkReply::NetworkError err = job->reply()->error(); #if QT_VERSION < QT_VERSION_CHECK(5, 4, 2) - if (err == QNetworkReply::OperationCanceledError && job->reply()->property(owncloudShouldSoftCancelPropertyName).isValid()) { - // Abort the job and try again later. + if (err == QNetworkReply::OperationCanceledError && job->reply()->property("owncloud-should-soft-cancel").isValid()) { // Abort the job and try again later. // This works around a bug in QNAM wich might reuse a non-empty buffer for the next request. qDebug() << "Forcing job abort on HTTP connection reset with Qt < 5.4.2."; _propagator->_anotherSyncNeeded = true;