[Pkg-owncloud-commits] [owncloud-client] 70/332: network limits: Do not read them from the config file in the engine

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 46b82606930367ec8b757d0cfdf1741fecb478cf
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Sat Jun 7 11:49:41 2014 +0200

    network limits: Do not read them from the config file in the engine
    
    Do that from the folder, because the engine can be used in app where
    the MirallConfigFile is not accessible
---
 src/mirall/folder.cpp     | 18 +++++++++++++++++-
 src/mirall/syncengine.cpp | 26 ++++++++------------------
 src/mirall/syncengine.h   |  2 +-
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 7e7ebdf..aa2a07b 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -604,6 +604,8 @@ void Folder::startSync(const QStringList &pathList)
                     SLOT(slotAboutToRemoveAllFiles(SyncFileItem::Direction,bool*)));
     connect(_engine.data(), SIGNAL(transmissionProgress(Progress::Info)), this, SLOT(slotTransmissionProgress(Progress::Info)));
 
+    setDirtyNetworkLimits();
+
     QMetaObject::invokeMethod(_engine.data(), "startSync", Qt::QueuedConnection);
 
     // disable events until syncing is done
@@ -615,7 +617,21 @@ void Folder::startSync(const QStringList &pathList)
 void Folder::setDirtyNetworkLimits()
 {
     if (_engine) {
-        _engine->setNetworkLimits();
+
+        MirallConfigFile cfg;
+        int downloadLimit = 0;
+        if (cfg.useDownloadLimit()) {
+            downloadLimit = cfg.downloadLimit() * 1000;
+        }
+        int uploadLimit = -75; // 75%
+        int useUpLimit = cfg.useUploadLimit();
+        if ( useUpLimit >= 1) {
+            uploadLimit = cfg.uploadLimit() * 1000;
+        } else if (useUpLimit == 0) {
+            uploadLimit = 0;
+        }
+
+        _engine->setNetworkLimits(uploadLimit, downloadLimit);
     }
 }
 
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index d3b55fa..b505a7b 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -15,7 +15,6 @@
 
 #include "mirall/syncengine.h"
 #include "mirall/account.h"
-#include "mirall/mirallconfigfile.h"
 #include "mirall/theme.h"
 #include "mirall/logger.h"
 #include "owncloudpropagator.h"
@@ -55,6 +54,7 @@ void csyncLogCatcher(int /*verbosity*/,
 bool SyncEngine::_syncRunning = false;
 
 SyncEngine::SyncEngine(CSYNC *ctx, const QString& localPath, const QString& remoteURL, const QString& remotePath, Mirall::SyncJournalDb* journal)
+    : _uploadLimit(0), _downloadLimit(0)
 {
     _localPath = localPath;
     _remotePath = remotePath;
@@ -586,31 +586,21 @@ void SyncEngine::slotUpdateFinished(int updateResult)
     connect(_propagator.data(), SIGNAL(adjustTotalTransmissionSize(qint64)), this, SLOT(slotAdjustTotalTransmissionSize(qint64)));
     connect(_propagator.data(), SIGNAL(finished()), this, SLOT(slotFinished()), Qt::QueuedConnection);
 
-    setNetworkLimits();
+    // apply the network limits to the propagator
+    setNetworkLimits(_uploadLimit, _downloadLimit);
 
     _propagator->start(_syncedItems);
 }
 
-void SyncEngine::setNetworkLimits()
+void SyncEngine::setNetworkLimits(int upload, int download)
 {
-    MirallConfigFile cfg;
+    _uploadLimit = upload;
+    _downloadLimit = download;
 
     if( !_propagator ) return;
 
-    int downloadLimit = 0;
-    if (cfg.useDownloadLimit()) {
-        downloadLimit = cfg.downloadLimit() * 1000;
-    }
-    _propagator->_downloadLimit = downloadLimit;
-
-    int uploadLimit = -75; // 75%
-    int useUpLimit = cfg.useUploadLimit();
-    if ( useUpLimit >= 1) {
-        uploadLimit = cfg.uploadLimit() * 1000;
-    } else if (useUpLimit == 0) {
-        uploadLimit = 0;
-    }
-    _propagator->_uploadLimit = uploadLimit;
+    _propagator->_uploadLimit = upload;
+    _propagator->_downloadLimit = download;
 
     int propDownloadLimit = _propagator->_downloadLimit
 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
diff --git a/src/mirall/syncengine.h b/src/mirall/syncengine.h
index 5f9c6e1..5d11d34 100644
--- a/src/mirall/syncengine.h
+++ b/src/mirall/syncengine.h
@@ -54,7 +54,7 @@ public:
     static QString csyncErrorToString( CSYNC_STATUS);
 
     Q_INVOKABLE void startSync();
-    Q_INVOKABLE void setNetworkLimits();
+    void setNetworkLimits(int upload, int download);
 
     /* Abort the sync.  Called from the main thread */
     void abort();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list