mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +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:
@@ -35,6 +35,7 @@ namespace Tomahawk
|
|||||||
namespace InfoSystem
|
namespace InfoSystem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const int InfoSystemCache::s_infosystemCacheVersion = 4;
|
||||||
|
|
||||||
InfoSystemCache::InfoSystemCache( QObject* parent )
|
InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
@@ -42,14 +43,10 @@ InfoSystemCache::InfoSystemCache( QObject* parent )
|
|||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
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 );
|
||||||
TomahawkUtils::removeDirectory( m_cacheBaseDir );
|
TomahawkSettings::instance()->setInfoSystemCacheVersion( s_infosystemCacheVersion );
|
||||||
#else
|
|
||||||
QDir(m_cacheBaseDir).removeRecursively();
|
|
||||||
#endif
|
|
||||||
TomahawkSettings::instance()->setInfoSystemCacheVersion( INFOSYSTEM_CACHE_VERSION );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pruneTimer.setInterval( 300000 );
|
m_pruneTimer.setInterval( 300000 );
|
||||||
|
@@ -34,8 +34,6 @@ namespace Tomahawk
|
|||||||
namespace InfoSystem
|
namespace InfoSystem
|
||||||
{
|
{
|
||||||
|
|
||||||
#define INFOSYSTEM_CACHE_VERSION 4
|
|
||||||
|
|
||||||
class DLLEXPORT InfoSystemCache : public QObject
|
class DLLEXPORT InfoSystemCache : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -56,6 +54,13 @@ private slots:
|
|||||||
void pruneTimerFired();
|
void pruneTimerFired();
|
||||||
|
|
||||||
private:
|
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 );
|
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;
|
const QString criteriaMd5( const Tomahawk::InfoSystem::InfoStringHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const;
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
using namespace TomahawkUtils;
|
using namespace TomahawkUtils;
|
||||||
|
|
||||||
Cache*Cache::s_instance = 0;
|
Cache*Cache::s_instance = 0;
|
||||||
|
const int Cache::s_cacheVersion = 1;
|
||||||
|
|
||||||
|
|
||||||
Cache* Cache::instance()
|
Cache* Cache::instance()
|
||||||
@@ -45,14 +46,10 @@ Cache::Cache()
|
|||||||
, m_cacheBaseDir( TomahawkSettings::instance()->storageCacheLocation() + "/GenericCache/" )
|
, m_cacheBaseDir( TomahawkSettings::instance()->storageCacheLocation() + "/GenericCache/" )
|
||||||
, m_cacheManifest( m_cacheBaseDir + "cachemanifest.ini", QSettings::IniFormat )
|
, 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 );
|
||||||
TomahawkUtils::removeDirectory( m_cacheBaseDir );
|
TomahawkSettings::instance()->setGenericCacheVersion( s_cacheVersion );
|
||||||
#else
|
|
||||||
QDir( m_cacheBaseDir ).removeRecursively();
|
|
||||||
#endif
|
|
||||||
TomahawkSettings::instance()->setGenericCacheVersion( CACHE_VERSION );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pruneTimer.setInterval( 300000 );
|
m_pruneTimer.setInterval( 300000 );
|
||||||
|
@@ -31,8 +31,6 @@
|
|||||||
namespace TomahawkUtils
|
namespace TomahawkUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
#define CACHE_VERSION 1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal data structure. Don't use.
|
* Internal data structure. Don't use.
|
||||||
*/
|
*/
|
||||||
@@ -89,6 +87,13 @@ private:
|
|||||||
Cache();
|
Cache();
|
||||||
static Cache* s_instance;
|
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.
|
* Adds a client to the manifest.
|
||||||
* Does not lock the mutex.
|
* Does not lock the mutex.
|
||||||
|
Reference in New Issue
Block a user