Changeset View
Changeset View
Standalone View
Standalone View
server/src/intervalcheck.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | void IntervalCheck::collectionExpired( const Collection &collection ) | ||||
const QDateTime now( QDateTime::currentDateTime() ); | const QDateTime now( QDateTime::currentDateTime() ); | ||||
if ( collection.parentId() == 0 ) { | if ( collection.parentId() == 0 ) { | ||||
const QString resourceName = collection.resource().name(); | const QString resourceName = collection.resource().name(); | ||||
const int interval = qMax( MINIMUM_COLTREESYNC_INTERVAL, collection.cachePolicyCheckInterval() ); | const int interval = qMax( MINIMUM_COLTREESYNC_INTERVAL, collection.cachePolicyCheckInterval() ); | ||||
const QDateTime lastExpectedCheck = now.addSecs( interval * -60 ); | const QDateTime lastExpectedCheck = now.addSecs( interval * -60 ); | ||||
if ( !mLastCollectionTreeSyncs.contains( resourceName ) || mLastCollectionTreeSyncs.value( resourceName ) < lastExpectedCheck ) { | if ( !mLastCollectionTreeSyncs.contains( resourceName ) || mLastCollectionTreeSyncs.value( resourceName ) < lastExpectedCheck.addSecs( 2 * -60 ) ) { | ||||
mLastCollectionTreeSyncs.insert( resourceName, now ); | mLastCollectionTreeSyncs.insert( resourceName, now ); | ||||
QMetaObject::invokeMethod( ItemRetrievalManager::instance(), "triggerCollectionTreeSync", | QMetaObject::invokeMethod( ItemRetrievalManager::instance(), "triggerCollectionTreeSync", | ||||
Qt::QueuedConnection, | Qt::QueuedConnection, | ||||
Q_ARG( QString, resourceName ) ); | Q_ARG( QString, resourceName ) ); | ||||
} | } | ||||
} | } | ||||
// now on to the actual collection syncing | // now on to the actual collection syncing | ||||
const int interval = qMax( MINIMUM_AUTOSYNC_INTERVAL, collection.cachePolicyCheckInterval() ); | const int interval = qMax( MINIMUM_AUTOSYNC_INTERVAL, collection.cachePolicyCheckInterval() ); | ||||
const QDateTime lastExpectedCheck = now.addSecs( interval * -60 ); | const QDateTime lastExpectedCheck = now.addSecs( interval * -60 ); | ||||
if ( mLastChecks.contains( collection.id() ) && mLastChecks.value( collection.id() ) > lastExpectedCheck ) { | //For an interval of 5min, we don't resync if we already did a sync within the last three minutes. | ||||
//Doing an exact check is too error prone, and can lead to not syncing for up to 2*interval()-1. | |||||
if ( mLastChecks.contains( collection.id() ) && mLastChecks.value( collection.id() ) > lastExpectedCheck.addSecs( 2 * -60 ) ) { | |||||
return; | return; | ||||
} | } | ||||
mLastChecks.insert( collection.id(), now ); | mLastChecks.insert( collection.id(), now ); | ||||
QMetaObject::invokeMethod( ItemRetrievalManager::instance(), "triggerCollectionSync", | QMetaObject::invokeMethod( ItemRetrievalManager::instance(), "triggerCollectionSync", | ||||
Qt::QueuedConnection, | Qt::QueuedConnection, | ||||
Q_ARG( QString, collection.resource().name() ), | Q_ARG( QString, collection.resource().name() ), | ||||
Q_ARG( qint64, collection.id() ) ); | Q_ARG( qint64, collection.id() ) ); | ||||
} | } |