mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Implement change of the network throttling during a running sync run.
This commit is contained in:
parent
08d08e1f29
commit
971caca5e8
8 changed files with 41 additions and 5 deletions
|
@ -431,10 +431,6 @@ void CSyncThread::startSync()
|
|||
}
|
||||
_abortRequestedMutex.unlock();
|
||||
|
||||
|
||||
// maybe move this somewhere else where it can influence a running sync?
|
||||
MirallConfigFile cfg;
|
||||
|
||||
if (!_journal->exists()) {
|
||||
qDebug() << "=====sync looks new (no DB exists), activating recursive PROPFIND if csync supports it";
|
||||
bool no_recursive_propfind = false;
|
||||
|
@ -562,6 +558,17 @@ void CSyncThread::startSync()
|
|||
connect(_propagator.data(), SIGNAL(progressChanged(qint64)), this, SLOT(slotProgressChanged(qint64)));
|
||||
connect(_propagator.data(), SIGNAL(finished()), this, SLOT(slotFinished()));
|
||||
|
||||
setNetworkLimits();
|
||||
|
||||
_propagator->start(_syncedItems);
|
||||
}
|
||||
|
||||
void CSyncThread::setNetworkLimits()
|
||||
{
|
||||
MirallConfigFile cfg;
|
||||
|
||||
if( !_propagator ) return;
|
||||
|
||||
int downloadLimit = 0;
|
||||
if (cfg.useDownloadLimit()) {
|
||||
downloadLimit = cfg.downloadLimit() * 1000;
|
||||
|
@ -577,7 +584,8 @@ void CSyncThread::startSync()
|
|||
}
|
||||
_propagator->_uploadLimit = uploadLimit;
|
||||
|
||||
_propagator->start(_syncedItems);
|
||||
qDebug() << " N------N Network Limits changed!";
|
||||
|
||||
}
|
||||
|
||||
void CSyncThread::transferCompleted(const SyncFileItem &item)
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
static QString csyncErrorToString( CSYNC_STATUS);
|
||||
|
||||
Q_INVOKABLE void startSync();
|
||||
Q_INVOKABLE void setNetworkLimits();
|
||||
|
||||
/* Abort the sync. Called from the main thread */
|
||||
void abort();
|
||||
|
|
|
@ -600,6 +600,13 @@ void Folder::startSync(const QStringList &pathList)
|
|||
emit syncStarted();
|
||||
}
|
||||
|
||||
void Folder::setDirtyNetworkLimits()
|
||||
{
|
||||
if( _csync ) {
|
||||
QMetaObject::invokeMethod(_csync, "setNetworkLimits", Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void Folder::slotCSyncError(const QString& err)
|
||||
{
|
||||
_errors.append( err );
|
||||
|
|
|
@ -134,6 +134,8 @@ public:
|
|||
|
||||
void setSyncState(SyncResult::Status state);
|
||||
|
||||
void setDirtyNetworkLimits();
|
||||
|
||||
signals:
|
||||
void syncStateChange();
|
||||
void syncStarted();
|
||||
|
|
|
@ -608,6 +608,16 @@ void FolderMan::setDirtyProxy(bool value)
|
|||
}
|
||||
}
|
||||
|
||||
void FolderMan::setDirtyNetworkLimits()
|
||||
{
|
||||
foreach( Folder *f, _folderMap.values() ) {
|
||||
// set only in busy folders. Otherwise they read the config anyway.
|
||||
if(f && f->isBusy()) {
|
||||
f->setDirtyNetworkLimits();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
|
||||
{
|
||||
|
|
|
@ -108,6 +108,7 @@ public slots:
|
|||
void slotScheduleAllFolders();
|
||||
|
||||
void setDirtyProxy(bool value = true);
|
||||
void setDirtyNetworkLimits();
|
||||
|
||||
// slot to add a folder to the syncing queue
|
||||
void slotScheduleSync( const QString & );
|
||||
|
|
|
@ -163,6 +163,8 @@ void NetworkSettings::saveBWLimitSettings()
|
|||
|
||||
cfgFile.setDownloadLimit(_ui->downloadSpinBox->value());
|
||||
cfgFile.setUploadLimit(_ui->uploadSpinBox->value());
|
||||
|
||||
FolderMan::instance()->setDirtyNetworkLimits();
|
||||
}
|
||||
|
||||
} // namespace Mirall
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <qstack.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <neon/ne_basic.h>
|
||||
#include <neon/ne_socket.h>
|
||||
|
@ -418,6 +419,7 @@ void PropagateUploadFile::notify_status_cb(void* userdata, ne_session_status sta
|
|||
that->_chunked_done + info->sr.progress,
|
||||
that->_chunked_total_size ? that->_chunked_total_size : info->sr.total );
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
that->limitBandwidth(that->_chunked_done + info->sr.progress, that->_propagator->_uploadLimit);
|
||||
}
|
||||
}
|
||||
|
@ -526,6 +528,7 @@ int PropagateDownloadFile::content_reader(void *userdata, const char *buf, size_
|
|||
}
|
||||
return NE_OK;
|
||||
}
|
||||
|
||||
return NE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -608,6 +611,8 @@ void PropagateDownloadFile::notify_status_cb(void* userdata, ne_session_status s
|
|||
PropagateDownloadFile* that = reinterpret_cast<PropagateDownloadFile*>(userdata);
|
||||
if (status == ne_status_recving && info->sr.total > 0) {
|
||||
emit that->progress(Progress::Context, that->_item, info->sr.progress, info->sr.total );
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
that->limitBandwidth(info->sr.progress, that->_propagator->_downloadLimit);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue