1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

Fix cache misses going to incorrect target

This commit is contained in:
Jeff Mitchell 2011-10-11 12:55:57 -04:00
parent a520f7bff3
commit c62c4fa1d9
5 changed files with 16 additions and 15 deletions

View File

@ -319,7 +319,7 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
default:
{
tLog() << "Couldn't figure out what to do with this type of request after cache miss";
tLog() << Q_FUNC_INFO << "Couldn't figure out what to do with this type of request after cache miss";
emit info( requestId, requestData, QVariant() );
return;
}

View File

@ -123,6 +123,7 @@ InfoSystemCache::pruneTimerFired()
void
InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData )
{
QObject* sendingObj = sender();
const QString criteriaHashVal = criteriaMd5( criteria );
const QString criteriaHashValWithType = criteriaMd5( criteria, requestData.type );
QHash< QString, QString > fileLocationHash = m_fileLocationCache[ requestData.type ];
@ -132,7 +133,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
{
//We already know of some values, so no need to re-read the directory again as it's already happened
qDebug() << Q_FUNC_INFO << "notInCache -- filelocationhash empty";
emit notInCache( requestId, criteria, requestData );
notInCache( sendingObj, requestId, criteria, requestData );
return;
}
@ -142,7 +143,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
{
//Dir doesn't exist so clearly not in cache
qDebug() << Q_FUNC_INFO << "notInCache -- dir doesn't exist";
emit notInCache( requestId, criteria, requestData );
notInCache( sendingObj, requestId, criteria, requestData );
return;
}
@ -159,7 +160,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
{
//Still didn't find it? It's really not in the cache then
qDebug() << Q_FUNC_INFO << "notInCache -- filelocationhash doesn't contain criteria val";
emit notInCache( requestId, criteria, requestData );
notInCache( sendingObj, requestId, criteria, requestData );
return;
}
}
@ -179,7 +180,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
m_dataCache.remove( criteriaHashValWithType );
qDebug() << Q_FUNC_INFO << "notInCache -- file was stale";
emit notInCache( requestId, criteria, requestData );
notInCache( sendingObj, requestId, criteria, requestData );
return;
}
else if ( newMaxAge > 0 )
@ -189,7 +190,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) )
{
qDebug() << Q_FUNC_INFO << "notInCache -- failed to move old cache file to new location";
emit notInCache( requestId, criteria, requestData );
notInCache( sendingObj, requestId, criteria, requestData );
return;
}
@ -212,6 +213,13 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
}
void
InfoSystemCache::notInCache( QObject *receiver, uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
QMetaObject::invokeMethod( receiver, "notInCacheSlot", Q_ARG( uint, requestId ), Q_ARG( Tomahawk::InfoSystem::InfoCriteriaHash, criteria ), Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
}
void
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
{

View File

@ -43,7 +43,6 @@ public:
virtual ~InfoSystemCache();
signals:
void notInCache( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
void info( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
public slots:
@ -54,6 +53,7 @@ private slots:
void pruneTimerFired();
private:
void notInCache( QObject *receiver, uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
void doUpgrade( uint oldVersion, uint newVersion );
const QString criteriaMd5( const Tomahawk::InfoSystem::InfoCriteriaHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const;

View File

@ -126,12 +126,6 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
cache.data(),
SLOT( getCachedInfoSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) )
);
connect(
cache.data(),
SIGNAL( notInCache( uint, Tomahawk::InfoSystem::InfoCriteriaHash, Tomahawk::InfoSystem::InfoRequestData ) ),
plugin.data(),
SLOT( notInCacheSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, Tomahawk::InfoSystem::InfoRequestData ) )
);
connect(
plugin.data(),
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),

View File

@ -70,14 +70,13 @@ private slots:
private:
void checkFinished( const QString &target );
QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
QHash< QString, QHash< InfoType, int > > m_dataTracker;
QMultiMap< qint64, uint > m_timeRequestMapper;
QHash< uint, bool > m_requestSatisfiedMap;
QHash< uint, InfoRequestData* > m_savedRequestMap;
QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
// For now, statically instantiate plugins; this is just somewhere to keep them
QList< InfoPluginPtr > m_plugins;