Chunking-NG: Qt4 compile

This commit is contained in:
Olivier Goffart 2016-08-03 17:43:03 +02:00
parent 79abb8b4e3
commit 818b5854ce
4 changed files with 20 additions and 17 deletions

View file

@ -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
};

View file

@ -307,6 +307,7 @@ private:
private slots:
void slotPropfindFinished();
void slotPropfindFinishedWithError();
void slotPropfindIterate(const QString &name, const QMap<QString,QString> &properties);
void slotMkColFinished(QNetworkReply::NetworkError);
void slotPutFinished();
void slotMoveJobFinished();

View file

@ -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<QString,QString> &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<QString,QString>)),
this, SLOT(slotPropfindIterate(QString,QMap<QString,QString>)));
job->start();
return;
}
@ -110,6 +99,18 @@ void PropagateUploadFileNG::doStartUpload()
startNewUpload();
}
void PropagateUploadFileNG::slotPropfindIterate(const QString &name, const QMap<QString,QString> &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<LsColJob *>(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.";

View file

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