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

Merge pull request #251 from tomahawk-player/cacheupdates

add genericcache version setting to TomahawkSettings, check for the cach...
This commit is contained in:
Uwe L. Korn
2014-09-11 23:29:32 +02:00
6 changed files with 44 additions and 1 deletions

View File

@@ -701,9 +701,20 @@ TomahawkSettings::setInfoSystemCacheVersion( uint version )
uint
TomahawkSettings::infoSystemCacheVersion() const
{
return value( "infosystemcacheversion", 3 ).toUInt();
return value( "infosystemcacheversion", 0 ).toUInt();
}
void
TomahawkSettings::setGenericCacheVersion( uint version )
{
setValue( "genericcacheversion", version );
}
uint
TomahawkSettings::genericCacheVersion() const
{
return value( "genericcacheversion", 0 ).toUInt();
}
QString
TomahawkSettings::storageCacheLocation() const

View File

@@ -60,6 +60,9 @@ public:
uint infoSystemCacheVersion() const;
void setInfoSystemCacheVersion( uint version );
uint genericCacheVersion() const;
void setGenericCacheVersion( uint version );
bool watchForChanges() const;
void setWatchForChanges( bool watch );

View File

@@ -35,6 +35,7 @@ namespace Tomahawk
namespace InfoSystem
{
const int InfoSystemCache::s_infosystemCacheVersion = 4;
InfoSystemCache::InfoSystemCache( QObject* parent )
: QObject( parent )
@@ -42,6 +43,12 @@ InfoSystemCache::InfoSystemCache( QObject* parent )
{
tDebug() << Q_FUNC_INFO;
if ( TomahawkSettings::instance()->infoSystemCacheVersion() < s_infosystemCacheVersion )
{
TomahawkUtils::removeDirectory( m_cacheBaseDir );
TomahawkSettings::instance()->setInfoSystemCacheVersion( s_infosystemCacheVersion );
}
m_pruneTimer.setInterval( 300000 );
m_pruneTimer.setSingleShot( false );
connect( &m_pruneTimer, SIGNAL( timeout() ), SLOT( pruneTimerFired() ) );

View File

@@ -54,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,6 +46,12 @@ Cache::Cache()
, m_cacheBaseDir( TomahawkSettings::instance()->storageCacheLocation() + "/GenericCache/" )
, m_cacheManifest( m_cacheBaseDir + "cachemanifest.ini", QSettings::IniFormat )
{
if ( TomahawkSettings::instance()->genericCacheVersion() < s_cacheVersion )
{
TomahawkUtils::removeDirectory( m_cacheBaseDir );
TomahawkSettings::instance()->setGenericCacheVersion( s_cacheVersion );
}
m_pruneTimer.setInterval( 300000 );
m_pruneTimer.setSingleShot( false );
connect( &m_pruneTimer, SIGNAL( timeout() ), SLOT( pruneTimerFired() ) );

View File

@@ -26,6 +26,7 @@
#include <QSettings>
#include <QObject>
#include <QTimer>
#include <QDir>
namespace TomahawkUtils
{
@@ -86,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.