diff --git a/src/libtomahawk/infosystem/InfoSystemCache.cpp b/src/libtomahawk/infosystem/InfoSystemCache.cpp index 80873bb48..159602d5d 100644 --- a/src/libtomahawk/infosystem/InfoSystemCache.cpp +++ b/src/libtomahawk/infosystem/InfoSystemCache.cpp @@ -35,6 +35,7 @@ namespace Tomahawk namespace InfoSystem { +const int InfoSystemCache::s_infosystemCacheVersion = 4; InfoSystemCache::InfoSystemCache( QObject* parent ) : QObject( parent ) @@ -42,14 +43,10 @@ InfoSystemCache::InfoSystemCache( QObject* parent ) { tDebug() << Q_FUNC_INFO; - if ( TomahawkSettings::instance()->infoSystemCacheVersion() < INFOSYSTEM_CACHE_VERSION ) + if ( TomahawkSettings::instance()->infoSystemCacheVersion() < s_infosystemCacheVersion ) { - #if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 ) - TomahawkUtils::removeDirectory( m_cacheBaseDir ); - #else - QDir(m_cacheBaseDir).removeRecursively(); - #endif - TomahawkSettings::instance()->setInfoSystemCacheVersion( INFOSYSTEM_CACHE_VERSION ); + TomahawkUtils::removeDirectory( m_cacheBaseDir ); + TomahawkSettings::instance()->setInfoSystemCacheVersion( s_infosystemCacheVersion ); } m_pruneTimer.setInterval( 300000 ); diff --git a/src/libtomahawk/infosystem/InfoSystemCache.h b/src/libtomahawk/infosystem/InfoSystemCache.h index 7c27b1bc5..bc3689e99 100644 --- a/src/libtomahawk/infosystem/InfoSystemCache.h +++ b/src/libtomahawk/infosystem/InfoSystemCache.h @@ -34,8 +34,6 @@ namespace Tomahawk namespace InfoSystem { -#define INFOSYSTEM_CACHE_VERSION 4 - class DLLEXPORT InfoSystemCache : public QObject { Q_OBJECT @@ -56,6 +54,13 @@ private slots: void pruneTimerFired(); private: + /** + * Version number of the infosystem cache. + * If you change existing cached data, + * increase this number. + */ + static const int s_infosystemCacheVersion; + void notInCache( QObject *receiver, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); const QString criteriaMd5( const Tomahawk::InfoSystem::InfoStringHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const; diff --git a/src/libtomahawk/utils/TomahawkCache.cpp b/src/libtomahawk/utils/TomahawkCache.cpp index de252708f..31bd581df 100644 --- a/src/libtomahawk/utils/TomahawkCache.cpp +++ b/src/libtomahawk/utils/TomahawkCache.cpp @@ -29,6 +29,7 @@ using namespace TomahawkUtils; Cache*Cache::s_instance = 0; +const int Cache::s_cacheVersion = 1; Cache* Cache::instance() @@ -45,14 +46,10 @@ Cache::Cache() , m_cacheBaseDir( TomahawkSettings::instance()->storageCacheLocation() + "/GenericCache/" ) , m_cacheManifest( m_cacheBaseDir + "cachemanifest.ini", QSettings::IniFormat ) { - if ( TomahawkSettings::instance()->genericCacheVersion() < CACHE_VERSION ) + if ( TomahawkSettings::instance()->genericCacheVersion() < s_cacheVersion ) { - #if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 ) - TomahawkUtils::removeDirectory( m_cacheBaseDir ); - #else - QDir( m_cacheBaseDir ).removeRecursively(); - #endif - TomahawkSettings::instance()->setGenericCacheVersion( CACHE_VERSION ); + TomahawkUtils::removeDirectory( m_cacheBaseDir ); + TomahawkSettings::instance()->setGenericCacheVersion( s_cacheVersion ); } m_pruneTimer.setInterval( 300000 ); diff --git a/src/libtomahawk/utils/TomahawkCache.h b/src/libtomahawk/utils/TomahawkCache.h index 682318aed..b7c3245f5 100644 --- a/src/libtomahawk/utils/TomahawkCache.h +++ b/src/libtomahawk/utils/TomahawkCache.h @@ -31,8 +31,6 @@ namespace TomahawkUtils { -#define CACHE_VERSION 1 - /** * Internal data structure. Don't use. */ @@ -89,6 +87,13 @@ private: Cache(); static Cache* s_instance; + /** + * Version number of the cache. + * If you change existing cached data, + * increase this number. + */ + static const int s_cacheVersion; + /** * Adds a client to the manifest. * Does not lock the mutex.