diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index c93ffe36f9e..3179585cffb 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -300,7 +300,8 @@ class PropagateUploadFileNG : public PropagateUploadFileCommon { // Map chunk number with its size from the PROPFIND on resume. // (Only used from slotPropfindIterate/slotPropfindFinished because the LsColJob use signals to report data.) - QMap _serverChunks; + struct ServerChunkInfo { quint64 size; QString originalName; }; + QMap _serverChunks; quint64 chunkSize() const { return propagator()->chunkSize(); } /** diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 09891b65b85..d42f3ecc5fe 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -41,7 +41,8 @@ QUrl PropagateUploadFileNG::chunkUrl(int chunk) + propagator()->account()->davUser() + QLatin1Char('/') + QString::number(_transferId); if (chunk >= 0) { - path += QLatin1Char('/') + QString::number(chunk); + // We need to do add leading 0 because the server orders the chunk alphabetically + path += QLatin1Char('/') + QString::number(chunk).rightJustified(8, '0'); } return Utility::concatUrlPath(propagator()->account()->url(), path); } @@ -108,9 +109,11 @@ void PropagateUploadFileNG::slotPropfindIterate(const QString &name, const QMap< return; // skip the info about the path itself } bool ok = false; - auto chunkId = name.mid(name.lastIndexOf('/')+1).toUInt(&ok); + QString chunkName = name.mid(name.lastIndexOf('/')+1); + auto chunkId = chunkName.toUInt(&ok); if (ok) { - _serverChunks[chunkId] = properties["getcontentlength"].toULongLong(); + ServerChunkInfo chunkinfo = { properties["getcontentlength"].toULongLong(), chunkName }; + _serverChunks[chunkId] = chunkinfo; } } @@ -123,7 +126,7 @@ void PropagateUploadFileNG::slotPropfindFinished() _currentChunk = 0; _sent = 0; while (_serverChunks.contains(_currentChunk)) { - _sent += _serverChunks[_currentChunk]; + _sent += _serverChunks[_currentChunk].size; _serverChunks.remove(_currentChunk); ++_currentChunk; } @@ -141,7 +144,7 @@ void PropagateUploadFileNG::slotPropfindFinished() qDebug() << "Resuming "<< _item->_file << " from chunk " << _currentChunk << "; sent ="<< _sent; if (!_serverChunks.isEmpty()) { - qDebug() << "To Delete" << _serverChunks; + qDebug() << "To Delete" << _serverChunks.keys(); propagator()->_activeJobList.append(this); _removeJobError = false; @@ -149,7 +152,7 @@ void PropagateUploadFileNG::slotPropfindFinished() // we should remove the later chunks. Otherwise when we do dynamic chunk sizing, we may end up // with corruptions if there are too many chunks, or if we abort and there are still stale chunks. for (auto it = _serverChunks.begin(); it != _serverChunks.end(); ++it) { - auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUrl(), QString::number(it.key())), this); + auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUrl(), it->originalName), this); QObject::connect(job, SIGNAL(finishedSignal()), this, SLOT(slotDeleteJobFinished())); _jobs.append(job); job->start(); diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h index 665dc201691..c5949524332 100644 --- a/test/syncenginetestutils.h +++ b/test/syncenginetestutils.h @@ -589,9 +589,10 @@ class FakeChunkMoveReply : public QNetworkReply char payload = '*'; do { - if (!sourceFolder->children.contains(QString::number(count))) + QString chunkName = QString::number(count).rightJustified(8, '0'); + if (!sourceFolder->children.contains(chunkName)) break; - auto &x = sourceFolder->children[QString::number(count)]; + auto &x = sourceFolder->children[chunkName]; Q_ASSERT(!x.isDir); Q_ASSERT(x.size > 0); // There should not be empty chunks size += x.size;