From f59515883dc6ee69f192e5a566f04b525e2d4e4b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 28 Jan 2015 11:23:20 +0100 Subject: [PATCH] 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. --- src/gui/folderman.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index e2671a31c9..853fef2c93 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -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); }