From d7c2b664abf4c5b5862fe688df8d5a3d538f7600 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Jan 2015 17:16:06 +0100 Subject: [PATCH] libsync: Get the maxParallel from the server If the server can't cope with parallel upload, it can advertise it in the capabilities secion Issue #2743 Need https://github.com/owncloud/core/pull/13628 --- src/libsync/owncloudpropagator.cpp | 14 ++++++++++---- src/libsync/owncloudpropagator.h | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 4c978580213..615c21506e5 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -28,6 +28,7 @@ #include "configfile.h" #include "utility.h" #include +#include "account.h" #ifdef Q_OS_WIN #include @@ -46,11 +47,16 @@ namespace OCC { /* The maximum number of active job in parallel */ int OwncloudPropagator::maximumActiveJob() { - static int max = qgetenv("OWNCLOUD_MAX_PARALLEL").toUInt(); - if (!max) { - max = 3; //default + if (_maxParallel <= 0) { + _maxParallel = qgetenv("OWNCLOUD_MAX_PARALLEL").toUInt(); + if (_maxParallel <= 0) { + _maxParallel = _account->capabilities().value("files").toMap().value("maxparallels").toInt(); + } + if (_maxParallel <= 0) { + _maxParallel = 3; // default value if the server says "O" or did not specify anything + } } - return max; + return _maxParallel; } /** Updates or creates a blacklist entry for the given item. diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 9c453f630c0..f88179e2bff 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -266,6 +266,7 @@ class OwncloudPropagator : public QObject { , _activeJobs(0) , _anotherSyncNeeded(false) , _account(account) + , _maxParallel(0) { } void start(const SyncFileItemVector &_syncedItems); @@ -339,6 +340,7 @@ private slots: private: AccountPtr _account; + int _maxParallel; /** Stores the time since a job touched a file. */ QHash _touchedFiles;