mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Force a sync run after 5 minutes
This commit is contained in:
parent
4e7c069c1f
commit
52a47fbc67
@ -56,6 +56,7 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
|
||||
, _csync_ctx(0)
|
||||
{
|
||||
qsrand(QTime::currentTime().msec());
|
||||
_timeSinceLastSync.start();
|
||||
|
||||
_watcher = new FolderWatcher(path, this);
|
||||
|
||||
@ -235,11 +236,17 @@ void Folder::evaluateSync(const QStringList &/*pathList*/)
|
||||
|
||||
void Folder::slotPollTimerTimeout()
|
||||
{
|
||||
qDebug() << "* Polling" << alias() << "for changes. Ignoring all pending events until now";
|
||||
qDebug() << "* Polling" << alias() << "for changes. Ignoring all pending events until now (time since next sync:" << (_timeSinceLastSync.elapsed() / 1000) << "s)";
|
||||
_watcher->clearPendingEvents();
|
||||
|
||||
QObject::connect(new RequestEtagJob(secondPath(), this), SIGNAL(etagRetreived(QString)),
|
||||
this, SLOT(etagRetreived(QString)));
|
||||
if (_timeSinceLastSync.elapsed() > MirallConfigFile().forceSyncInterval()) {
|
||||
qDebug() << "* Force Sync now";
|
||||
evaluateSync(QStringList());
|
||||
} else {
|
||||
// check if the etag is different
|
||||
QObject::connect(new RequestEtagJob(secondPath(), this), SIGNAL(etagRetreived(QString)),
|
||||
this, SLOT(etagRetreived(QString)));
|
||||
}
|
||||
}
|
||||
|
||||
void Folder::etagRetreived(const QString& etag)
|
||||
@ -262,6 +269,7 @@ void Folder::slotSyncFinished(const SyncResult &result)
|
||||
{
|
||||
_watcher->setEventsEnabledDelayed(2000);
|
||||
_pollTimer.start();
|
||||
_timeSinceLastSync.restart();
|
||||
|
||||
qDebug() << "OO folder slotSyncFinished: result: " << int(result.status());
|
||||
emit syncStateChange();
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <qelapsedtimer.h>
|
||||
|
||||
class QFileSystemWatcher;
|
||||
class QThread;
|
||||
@ -213,6 +214,7 @@ protected:
|
||||
Progress::Kind _progressKind;
|
||||
QTimer _pollTimer;
|
||||
QString _lastEtag;
|
||||
QElapsedTimer _timeSinceLastSync;
|
||||
|
||||
CSYNC *_csync_ctx;
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ static const char authTypeC[] = "authType";
|
||||
|
||||
static const char caCertsKeyC[] = "CaCertificates";
|
||||
static const char remotePollIntervalC[] = "remotePollInterval";
|
||||
static const char forceSyncIntervalC[] = "forceSyncInterval";
|
||||
static const char monoIconsC[] = "monoIcons";
|
||||
static const char optionalDesktopNoficationsC[] = "optionalDesktopNotifications";
|
||||
static const char skipUpdateCheckC[] = "skipUpdateCheck";
|
||||
@ -390,6 +391,24 @@ void MirallConfigFile::setRemotePollInterval(int interval, const QString &connec
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
quint64 MirallConfigFile::forceSyncInterval(const QString& connection) const
|
||||
{
|
||||
uint pollInterval = remotePollInterval(connection);
|
||||
|
||||
QString con( connection );
|
||||
if( connection.isEmpty() ) con = defaultConnection();
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.setIniCodec("UTF-8");
|
||||
settings.beginGroup( con );
|
||||
|
||||
quint64 interval = settings.value( QLatin1String(forceSyncIntervalC), 10 * pollInterval ).toULongLong();
|
||||
if( interval < pollInterval) {
|
||||
qDebug() << "Force sync interval is less than the remote poll inteval, reverting to" << pollInterval;
|
||||
interval = pollInterval;
|
||||
}
|
||||
return interval;
|
||||
}
|
||||
|
||||
QString MirallConfigFile::ownCloudVersion() const
|
||||
{
|
||||
return _oCVersion;
|
||||
|
||||
@ -72,6 +72,9 @@ public:
|
||||
/* Set poll interval. Value in microseconds has to be larger than 5000 */
|
||||
void setRemotePollInterval(int interval, const QString& connection = QString() );
|
||||
|
||||
/* Force sync interval, in milliseconds */
|
||||
quint64 forceSyncInterval(const QString &connection = QString()) const;
|
||||
|
||||
// Custom Config: accept the custom config to become the main one.
|
||||
void acceptCustomConfig();
|
||||
// Custom Config: remove the custom config file.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user