Skip to content

Commit

Permalink
libsync: Get the maxParallel from the server
Browse files Browse the repository at this point in the history
If the server can't cope with parallel upload, it can advertise it
in the capabilities secion

Issue #2743
Need owncloud/core#13628
  • Loading branch information
ogoffart committed Feb 5, 2015
1 parent 856df4c commit d7c2b66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "configfile.h"
#include "utility.h"
#include <json.h>
#include "account.h"

#ifdef Q_OS_WIN
#include <windef.h>
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/owncloudpropagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class OwncloudPropagator : public QObject {
, _activeJobs(0)
, _anotherSyncNeeded(false)
, _account(account)
, _maxParallel(0)
{ }

void start(const SyncFileItemVector &_syncedItems);
Expand Down Expand Up @@ -339,6 +340,7 @@ private slots:
private:

AccountPtr _account;
int _maxParallel;

/** Stores the time since a job touched a file. */
QHash<QString, QElapsedTimer> _touchedFiles;
Expand Down

0 comments on commit d7c2b66

Please sign in to comment.