From d781e63fabd9de1c2ed58860b81cf555dcc7b36f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Piotr=20Mr=C3=B3wczy=C5=84ski?= Date: Wed, 21 Dec 2016 15:08:45 +0100 Subject: [PATCH] Add capability to disable parallel chunked upload #5364 - technical review (#5403) --- src/libsync/capabilities.cpp | 4 ++++ src/libsync/capabilities.h | 3 +++ src/libsync/propagateuploadv1.cpp | 23 +++++++++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index 31cd76b4c..5bd5d1c4c 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -116,5 +116,9 @@ bool Capabilities::chunkingNg() const return _capabilities["dav"].toMap()["chunking"].toByteArray() >= "1.0"; } +bool Capabilities::chunkingParallelUploadDisabled() const +{ + return _capabilities["dav"].toMap()["chunkingParallelUploadDisabled"].toBool(); +} } diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h index 861cf18ae..76e2b6f22 100644 --- a/src/libsync/capabilities.h +++ b/src/libsync/capabilities.h @@ -42,6 +42,9 @@ public: bool shareResharing() const; bool chunkingNg() const; + /// disable parallel upload in chunking + bool chunkingParallelUploadDisabled() const; + /// returns true if the capabilities report notifications bool notificationsAvailable() const; diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index 58dbf59bd..2e68fe529 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -134,18 +134,25 @@ void PropagateUploadFileV1::startNextChunk() _currentChunk++; bool parallelChunkUpload = true; - QByteArray env = qgetenv("OWNCLOUD_PARALLEL_CHUNK"); - if (!env.isEmpty()) { - parallelChunkUpload = env != "false" && env != "0"; + + if (_propagator->account()->capabilities().chunkingParallelUploadDisabled()) { + // Server may also disable parallel chunked upload for any higher version + parallelChunkUpload = false; } else { - int versionNum = _propagator->account()->serverVersionInt(); - if (versionNum < 0x080003) { - // Disable parallel chunk upload severs older than 8.0.3 to avoid too many - // internal sever errors (#2743, #2938) - parallelChunkUpload = false; + QByteArray env = qgetenv("OWNCLOUD_PARALLEL_CHUNK"); + if (!env.isEmpty()) { + parallelChunkUpload = env != "false" && env != "0"; + } else { + int versionNum = _propagator->account()->serverVersionInt(); + if (versionNum < 0x080003) { + // Disable parallel chunk upload severs older than 8.0.3 to avoid too many + // internal sever errors (#2743, #2938) + parallelChunkUpload = false; + } } } + if (_currentChunk + _startChunk >= _chunkCount - 1) { // Don't do parallel upload of chunk if this might be the last chunk because the server cannot handle that // https://github.com/owncloud/core/issues/11106 -- 2.30.2