mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Don't let cache requests go through until the cache is fully loaded
This commit is contained in:
@@ -33,6 +33,7 @@ namespace InfoSystem
|
||||
|
||||
InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||
: QObject(parent)
|
||||
, m_cacheRemainingToLoad( 0 )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
|
||||
@@ -43,7 +44,10 @@ InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||
QString cacheFile = cacheDir + '/' + QString::number( i );
|
||||
QDir dir( cacheDir );
|
||||
if( dir.exists() && QFile::exists( cacheFile ) )
|
||||
{
|
||||
m_cacheRemainingToLoad++;
|
||||
QMetaObject::invokeMethod( this, "loadCache", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QString, cacheFile ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +78,13 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria crit
|
||||
emit notInCache( criteria, caller, type, input, customData );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_cacheRemainingToLoad > 0 )
|
||||
{
|
||||
qDebug() << "Cache not fully loaded, punting request for a bit";
|
||||
QMetaObject::invokeMethod( this, "getCachedInfoSlot", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoCacheCriteria, criteria ), Q_ARG( qint64, newMaxAge ), Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::InfoCustomData, customData ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
|
||||
|
||||
@@ -153,6 +164,7 @@ InfoSystemCache::loadCache( Tomahawk::InfoSystem::InfoType type, const QString &
|
||||
m_insertTimeCache[type] = insertDateHash;
|
||||
m_maxTimeCache[type] = maxDateHash;
|
||||
}
|
||||
m_cacheRemainingToLoad--;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -57,6 +57,7 @@ private:
|
||||
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_insertTimeCache;
|
||||
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_maxTimeCache;
|
||||
QSet< InfoType > m_dirtySet;
|
||||
int m_cacheRemainingToLoad;
|
||||
};
|
||||
|
||||
} //namespace InfoSystem
|
||||
|
Reference in New Issue
Block a user