mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-03 12:47:45 +02:00
Fix cache misses going to incorrect target
This commit is contained in:
@@ -319,7 +319,7 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
|||||||
|
|
||||||
default:
|
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() );
|
emit info( requestId, requestData, QVariant() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -123,6 +123,7 @@ InfoSystemCache::pruneTimerFired()
|
|||||||
void
|
void
|
||||||
InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData )
|
InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||||
{
|
{
|
||||||
|
QObject* sendingObj = sender();
|
||||||
const QString criteriaHashVal = criteriaMd5( criteria );
|
const QString criteriaHashVal = criteriaMd5( criteria );
|
||||||
const QString criteriaHashValWithType = criteriaMd5( criteria, requestData.type );
|
const QString criteriaHashValWithType = criteriaMd5( criteria, requestData.type );
|
||||||
QHash< QString, QString > fileLocationHash = m_fileLocationCache[ 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
|
//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";
|
qDebug() << Q_FUNC_INFO << "notInCache -- filelocationhash empty";
|
||||||
emit notInCache( requestId, criteria, requestData );
|
notInCache( sendingObj, requestId, criteria, requestData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +143,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
|
|||||||
{
|
{
|
||||||
//Dir doesn't exist so clearly not in cache
|
//Dir doesn't exist so clearly not in cache
|
||||||
qDebug() << Q_FUNC_INFO << "notInCache -- dir doesn't exist";
|
qDebug() << Q_FUNC_INFO << "notInCache -- dir doesn't exist";
|
||||||
emit notInCache( requestId, criteria, requestData );
|
notInCache( sendingObj, requestId, criteria, requestData );
|
||||||
return;
|
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
|
//Still didn't find it? It's really not in the cache then
|
||||||
qDebug() << Q_FUNC_INFO << "notInCache -- filelocationhash doesn't contain criteria val";
|
qDebug() << Q_FUNC_INFO << "notInCache -- filelocationhash doesn't contain criteria val";
|
||||||
emit notInCache( requestId, criteria, requestData );
|
notInCache( sendingObj, requestId, criteria, requestData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +180,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
|
|||||||
m_dataCache.remove( criteriaHashValWithType );
|
m_dataCache.remove( criteriaHashValWithType );
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "notInCache -- file was stale";
|
qDebug() << Q_FUNC_INFO << "notInCache -- file was stale";
|
||||||
emit notInCache( requestId, criteria, requestData );
|
notInCache( sendingObj, requestId, criteria, requestData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ( newMaxAge > 0 )
|
else if ( newMaxAge > 0 )
|
||||||
@@ -189,7 +190,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCr
|
|||||||
if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) )
|
if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "notInCache -- failed to move old cache file to new location";
|
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;
|
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
|
void
|
||||||
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
||||||
{
|
{
|
||||||
|
@@ -43,7 +43,6 @@ public:
|
|||||||
virtual ~InfoSystemCache();
|
virtual ~InfoSystemCache();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notInCache( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
|
||||||
void info( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void info( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -54,6 +53,7 @@ private slots:
|
|||||||
void pruneTimerFired();
|
void pruneTimerFired();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void notInCache( QObject *receiver, uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||||
void doUpgrade( uint oldVersion, uint newVersion );
|
void doUpgrade( uint oldVersion, uint newVersion );
|
||||||
const QString criteriaMd5( const Tomahawk::InfoSystem::InfoCriteriaHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const;
|
const QString criteriaMd5( const Tomahawk::InfoSystem::InfoCriteriaHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const;
|
||||||
|
|
||||||
|
@@ -126,12 +126,6 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
|
|||||||
cache.data(),
|
cache.data(),
|
||||||
SLOT( getCachedInfoSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) )
|
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(
|
connect(
|
||||||
plugin.data(),
|
plugin.data(),
|
||||||
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
||||||
|
@@ -70,14 +70,13 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void checkFinished( const QString &target );
|
void checkFinished( const QString &target );
|
||||||
|
QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
|
||||||
|
|
||||||
QHash< QString, QHash< InfoType, int > > m_dataTracker;
|
QHash< QString, QHash< InfoType, int > > m_dataTracker;
|
||||||
QMultiMap< qint64, uint > m_timeRequestMapper;
|
QMultiMap< qint64, uint > m_timeRequestMapper;
|
||||||
QHash< uint, bool > m_requestSatisfiedMap;
|
QHash< uint, bool > m_requestSatisfiedMap;
|
||||||
QHash< uint, InfoRequestData* > m_savedRequestMap;
|
QHash< uint, InfoRequestData* > m_savedRequestMap;
|
||||||
|
|
||||||
QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
|
|
||||||
|
|
||||||
// For now, statically instantiate plugins; this is just somewhere to keep them
|
// For now, statically instantiate plugins; this is just somewhere to keep them
|
||||||
QList< InfoPluginPtr > m_plugins;
|
QList< InfoPluginPtr > m_plugins;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user