1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 06:36:55 +02:00

Add version controll to force cacheupdates on new sources.

This commit is contained in:
Hugo Lindström
2012-01-25 16:40:59 +01:00
parent 78ad724bac
commit 47529ee4d8
2 changed files with 10 additions and 8 deletions

View File

@@ -46,6 +46,8 @@ ChartsPlugin::ChartsPlugin()
{ {
/// Add resources here /// Add resources here
m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted" << "ex.fm" << "soundcloudwall.com"; m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted" << "ex.fm" << "soundcloudwall.com";
/// If you add resource, update version aswell
m_chartVersion = "1.0";
m_supportedGetTypes << InfoChart << InfoChartCapabilities; m_supportedGetTypes << InfoChart << InfoChartCapabilities;
} }
@@ -153,7 +155,8 @@ ChartsPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requ
Tomahawk::InfoSystem::InfoStringHash criteria; Tomahawk::InfoSystem::InfoStringHash criteria;
criteria[ "InfoChartCapabilities" ] = "chartsplugin"; criteria[ "InfoChartCapabilities" ] = "chartsplugin";
emit getCachedInfo( criteria, 604800000, requestData ); criteria[ "InfoChartVersion" ] = m_chartVersion;
emit getCachedInfo( criteria, 864000000, requestData );
} }
void void
@@ -182,8 +185,8 @@ ChartsPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSy
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities not in cache! Fetching..."; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities not in cache! Fetching...";
// we never need to re-fetch // we never need to re-fetch
if ( !m_allChartsMap.isEmpty() ) //if ( !m_allChartsMap.isEmpty() )
return; // return;
/// Then get each chart from resource /// Then get each chart from resource
@@ -333,6 +336,7 @@ ChartsPlugin::chartTypes()
if( source == "wearehunted" ){ if( source == "wearehunted" ){
chartName = "WeAreHunted"; chartName = "WeAreHunted";
} }
} }
} }
@@ -422,7 +426,8 @@ ChartsPlugin::chartTypes()
// update cache // update cache
Tomahawk::InfoSystem::InfoStringHash criteria; Tomahawk::InfoSystem::InfoStringHash criteria;
criteria[ "InfoChartCapabilities" ] = "chartsplugin"; criteria[ "InfoChartCapabilities" ] = "chartsplugin";
emit updateCache( criteria, 604800000, request.type, m_allChartsMap ); criteria[ "InfoChartVersion" ] = m_chartVersion;
emit updateCache( criteria, 864000000, request.type, m_allChartsMap );
} }
m_cachedRequests.clear(); m_cachedRequests.clear();
} }

View File

@@ -72,16 +72,13 @@ private:
void dataError( Tomahawk::InfoSystem::InfoRequestData requestData ); void dataError( Tomahawk::InfoSystem::InfoRequestData requestData );
QStringList m_chartResources; QStringList m_chartResources;
QString m_chartVersion;
QList< InfoStringHash > m_charts; QList< InfoStringHash > m_charts;
ChartType m_chartType; ChartType m_chartType;
QVariantMap m_allChartsMap; QVariantMap m_allChartsMap;
uint m_chartsFetchJobs; uint m_chartsFetchJobs;
QList< InfoRequestData > m_cachedRequests; QList< InfoRequestData > m_cachedRequests;
QHash< QString, QString > m_cachedCountries; QHash< QString, QString > m_cachedCountries;
QWeakPointer< QNetworkAccessManager > m_nam; QWeakPointer< QNetworkAccessManager > m_nam;
}; };