FolderMan: Require 2s minimum delay.

Otherwise we run into "can't upload because it's too recent" issues
when the folder watcher triggers a sync.

We used to do this, but my recent refactoring started counting the
time since the last sync against this minimum delay, leading to
1ms delays in practice. This fixes the regression.
This commit is contained in:
Christian Kamm 2015-01-28 11:23:20 +01:00
parent 2c432e0b97
commit f59515883d

View file

@ -564,16 +564,18 @@ void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
}
}
// A minimum of delay here is essential as the sync will not upload
// files that were changed too recently.
msDelay = qMax(msDelay, msBetweenRequestAndSync);
// Delays beyond one minute seem too big, particularly since there
// could be things later in the queue that shouldn't be punished by a
// long delay!
msDelay = qMin(msDelay, 60*1000ll);
// Time since the last sync run counts against the delay
msDelay = qMax(1ll, msDelay - msSinceLastSync);
// A minimum of delay here is essential as the sync will not upload
// files that were changed too recently.
msDelay = qMax(msBetweenRequestAndSync, msDelay);
qDebug() << "Scheduling a sync in" << (msDelay/1000) << "seconds";
_startScheduledSyncTimer.start(msDelay);
}