1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 09:34:53 +02:00

change DEFINES to c++ constants, remove qt5 ifdefs inside Generic/InfosystemCache and let TomahawkUtils handle the version check

This commit is contained in:
Stefan Derkits
2014-09-11 10:48:53 +02:00
parent 2797c06a8c
commit b4a290c8ec
4 changed files with 22 additions and 18 deletions

View File

@@ -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 );

View File

@@ -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;

View File

@@ -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 );

View File

@@ -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.