mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Set a variable poll timer interval, useful for multiple folders.
Start polltimer again after folder add.
This commit is contained in:
parent
df2d745747
commit
949b33a6d1
4 changed files with 12 additions and 6 deletions
|
@ -63,9 +63,7 @@ void CSyncThread::run()
|
|||
return;
|
||||
qDebug() << "## CSync Thread local only: " << _localCheckOnly;
|
||||
|
||||
#if LIBCSYNC_VERSION_INT >= CSYNC_VERSION_INT(0, 45, 0)
|
||||
csync_enable_conflictcopys(csync);
|
||||
#endif
|
||||
|
||||
QTime t;
|
||||
t.start();
|
||||
|
|
|
@ -35,8 +35,11 @@ Folder::Folder(const QString &alias, const QString &path, QObject *parent)
|
|||
_online(false),
|
||||
_enabled(true)
|
||||
{
|
||||
qsrand(time(0));
|
||||
|
||||
_pollTimer->setSingleShot(true);
|
||||
_pollTimer->setInterval( DEFAULT_POLL_INTERVAL_SEC );
|
||||
int polltime = DEFAULT_POLL_INTERVAL_SEC - 2000+ (int)( 4000.0*qrand()/(RAND_MAX+1.0));
|
||||
_pollTimer->setInterval( polltime );
|
||||
|
||||
QObject::connect(_pollTimer, SIGNAL(timeout()), this, SLOT(slotPollTimerTimeout()));
|
||||
_pollTimer->start();
|
||||
|
@ -83,6 +86,9 @@ void Folder::setSyncEnabled( bool doit )
|
|||
#ifdef USE_WATCHER
|
||||
_watcher->setEventsEnabled( doit );
|
||||
#endif
|
||||
if( doit && ! _pollTimer->isActive() ) {
|
||||
_pollTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
bool Folder::onlyOnlineEnabled() const
|
||||
|
@ -205,7 +211,7 @@ void Folder::slotSyncFinished(const SyncResult &result)
|
|||
|
||||
// reenable the poll timer if folder is sync enabled
|
||||
if( syncEnabled() ) {
|
||||
qDebug() << "* " << alias() << "Poll timer enabled with " << _pollTimer->interval() << "seconds";
|
||||
qDebug() << "* " << alias() << "Poll timer enabled with " << _pollTimer->interval() << "milliseconds";
|
||||
_pollTimer->start();
|
||||
} else {
|
||||
qDebug() << "* Not enabling poll timer for " << alias();
|
||||
|
|
|
@ -197,7 +197,7 @@ void FolderMan::restoreEnabledFolders()
|
|||
{
|
||||
foreach( Folder *f, _folderMap ) {
|
||||
if (_folderEnabledMap.contains( f->alias() )) {
|
||||
f->setSyncEnabled( _folderEnabledMap.value( f->alias() ));
|
||||
f->setSyncEnabled( _folderEnabledMap.value( f->alias() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ ownCloudFolder::ownCloudFolder(const QString &alias,
|
|||
|
||||
{
|
||||
#ifdef USE_WATCHER
|
||||
setPollInterval( 15000 );
|
||||
qDebug() << "****** ownCloud folder using watcher *******";
|
||||
// The folder interval is set in the folder parent class.
|
||||
#else
|
||||
/* If local polling is used, the polltimer of class Folder has to fire more
|
||||
* often
|
||||
|
@ -50,8 +50,10 @@ ownCloudFolder::ownCloudFolder(const QString &alias,
|
|||
* remote poll interval, defined in slotPollTimerRemoteCheck
|
||||
*/
|
||||
|
||||
_pollTimer->stop();
|
||||
connect( _pollTimer, SIGNAL(timeout()), this, SLOT(slotPollTimerRemoteCheck()));
|
||||
setPollInterval( 2000 );
|
||||
_pollTimer->start();
|
||||
qDebug() << "****** ownCloud folder using local poll *******";
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue