diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 94d87c39c1b..1b96dabf837 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -57,6 +57,11 @@ Account::~Account() QString Account::davPath() const { + if (capabilities().chunkingNg()) { + // The chunking-ng means the server prefer to use the new webdav URL + return QLatin1String("/remote.php/dav/files/") + davUser() + QLatin1Char('/'); + } + // make sure to have a trailing slash if( !_davPath.endsWith('/') ) { QString dp(_davPath); diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index 14acfa3a6b6..31cd76b4c2c 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -110,6 +110,9 @@ QByteArray Capabilities::uploadChecksumType() const bool Capabilities::chunkingNg() const { + static const auto chunkng = qgetenv("OWNCLOUD_CHUNKING_NG"); + if (chunkng == "0") return false; + if (chunkng == "1") return true; return _capabilities["dav"].toMap()["chunking"].toByteArray() >= "1.0"; } diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index f31aa167605..38011862d6f 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -271,9 +271,7 @@ PropagateItemJob* OwncloudPropagator::createJob(const SyncFileItemPtr &item) { return job; } else { PropagateUploadFileCommon *job = 0; - static const auto chunkng = qgetenv("OWNCLOUD_CHUNKING_NG"); - if (item->_size > chunkSize() - && (account()->capabilities().chunkingNg() || chunkng == "1") && chunkng != "0") { + if (item->_size > chunkSize() && account()->capabilities().chunkingNg()) { job = new PropagateUploadFileNG(this, item); } else { job = new PropagateUploadFileV1(this, item); diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 7b10288ede1..106b0dcdb2f 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -268,10 +268,8 @@ void PropagateUploadFileNG::startNextChunk() Q_ASSERT(_jobs.isEmpty()); // There should be no running job anymore _finished = true; // Finish with a MOVE - QString destination = _propagator->account()->url().path() - + QLatin1String("/remote.php/dav/files/") + _propagator->account()->davUser() - + _propagator->_remoteFolder + _item->_file; - + QString destination = QDir::cleanPath(_propagator->account()->url().path() + QLatin1Char('/') + + _propagator->account()->davPath() + _propagator->_remoteFolder + _item->_file); auto headers = PropagateUploadFileCommon::headers(); // "If-Match applies to the source, but we are interested in comparing the etag of the destination