mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
Sync scheduling: Only retry up to twice after fail. #2386
Previously when a sync failed, we'd retry very soon (30s) no matter how often a sync had failed before. After this change we'll retry twice and then back off to the regular 5min interval.
This commit is contained in:
parent
f5c199740d
commit
82b14370fc
2 changed files with 20 additions and 6 deletions
|
@ -61,6 +61,7 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
|
|||
, _wipeDb(false)
|
||||
, _proxyDirty(true)
|
||||
, _forceSyncOnPollTimeout(false)
|
||||
, _consecutiveFailingSyncs(0)
|
||||
, _journal(path)
|
||||
, _csync_ctx(0)
|
||||
{
|
||||
|
@ -272,12 +273,10 @@ void Folder::slotPollTimerTimeout()
|
|||
|
||||
bool forceSyncIntervalExpired =
|
||||
quint64(_timeSinceLastSync.elapsed()) > MirallConfigFile().forceSyncInterval();
|
||||
bool okSyncResult =
|
||||
_syncResult.status() == SyncResult::Success ||
|
||||
_syncResult.status() == SyncResult::Problem;
|
||||
bool syncAgainAfterFail = _consecutiveFailingSyncs > 0 && _consecutiveFailingSyncs < 3;
|
||||
if (forceSyncIntervalExpired ||
|
||||
_forceSyncOnPollTimeout ||
|
||||
!okSyncResult) {
|
||||
syncAgainAfterFail) {
|
||||
if (forceSyncIntervalExpired) {
|
||||
qDebug() << "** Force Sync, because it has been " << _timeSinceLastSync.elapsed() << "ms "
|
||||
<< "since the last sync";
|
||||
|
@ -285,8 +284,10 @@ void Folder::slotPollTimerTimeout()
|
|||
if (_forceSyncOnPollTimeout) {
|
||||
qDebug() << "** Force Sync, because it was requested";
|
||||
}
|
||||
if (!okSyncResult) {
|
||||
qDebug() << "** Force Sync, because the last sync had status: " << _syncResult.statusString();
|
||||
if (syncAgainAfterFail) {
|
||||
qDebug() << "** Force Sync, because the last"
|
||||
<< _consecutiveFailingSyncs << "syncs failed, last status:"
|
||||
<< _syncResult.statusString();
|
||||
}
|
||||
_forceSyncOnPollTimeout = false;
|
||||
emit scheduleToSync(alias());
|
||||
|
@ -830,6 +831,18 @@ void Folder::slotSyncFinished()
|
|||
_syncResult.setStatus(SyncResult::Success);
|
||||
}
|
||||
|
||||
// Count the number of syncs that have failed in a row.
|
||||
if (_syncResult.status() == SyncResult::Success
|
||||
|| _syncResult.status() == SyncResult::Problem)
|
||||
{
|
||||
_consecutiveFailingSyncs = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_consecutiveFailingSyncs++;
|
||||
qDebug() << "the last" << _consecutiveFailingSyncs << "syncs failed";
|
||||
}
|
||||
|
||||
emit syncStateChange();
|
||||
|
||||
// The syncFinished result that is to be triggered here makes the folderman
|
||||
|
|
|
@ -203,6 +203,7 @@ private:
|
|||
QString _lastEtag;
|
||||
QElapsedTimer _timeSinceLastSync;
|
||||
bool _forceSyncOnPollTimeout;
|
||||
int _consecutiveFailingSyncs;
|
||||
|
||||
// For the SocketAPI folder states
|
||||
QSet<QString> _stateLastSyncItemsWithErrorNew; // gets moved to _stateLastSyncItemsWithError at end of sync
|
||||
|
|
Loading…
Reference in a new issue