mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Get rid of InfoSystemCache version
This commit is contained in:
parent
ea6374c515
commit
6c55f8c4a0
@ -43,24 +43,8 @@ namespace InfoSystem
|
||||
InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_cacheBaseDir( TomahawkSettings::instance()->storageCacheLocation() + "/InfoSystemCache/" )
|
||||
, m_cacheVersion( 3 )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
TomahawkSettings *s = TomahawkSettings::instance();
|
||||
if ( s->infoSystemCacheVersion() != m_cacheVersion )
|
||||
{
|
||||
tLog() << "Cache version outdated, old:" << s->infoSystemCacheVersion()
|
||||
<< "new:" << m_cacheVersion
|
||||
<< "Doing upgrade, if any...";
|
||||
|
||||
uint current = s->infoSystemCacheVersion();
|
||||
while( current < m_cacheVersion )
|
||||
{
|
||||
doUpgrade( current, current + 1 );
|
||||
current++;
|
||||
}
|
||||
s->setInfoSystemCacheVersion( m_cacheVersion );
|
||||
}
|
||||
|
||||
m_pruneTimer.setInterval( 300000 );
|
||||
m_pruneTimer.setSingleShot( false );
|
||||
@ -75,49 +59,6 @@ InfoSystemCache::~InfoSystemCache()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::performWipe( QString directory )
|
||||
{
|
||||
QDir dir;
|
||||
for ( int i = InfoNoInfo; i <= InfoLastInfo; i++ )
|
||||
{
|
||||
InfoType type = (InfoType)(i);
|
||||
const QString cacheDirName = directory + QString::number( (int)type );
|
||||
QFileInfoList fileList = QDir( cacheDirName ).entryInfoList( QDir::Files | QDir::NoDotAndDotDot );
|
||||
foreach ( QFileInfo file, fileList )
|
||||
{
|
||||
if ( !QFile::remove( file.canonicalFilePath() ) )
|
||||
tLog() << "During upgrade, failed to remove cache file " << file.canonicalFilePath();
|
||||
}
|
||||
dir.rmdir( cacheDirName );
|
||||
}
|
||||
dir.rmdir( directory );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::doUpgrade( uint oldVersion, uint newVersion )
|
||||
{
|
||||
Q_UNUSED( newVersion );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( oldVersion == 0 || oldVersion == 1 )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Wiping cache";
|
||||
|
||||
performWipe( m_cacheBaseDir );
|
||||
}
|
||||
|
||||
if ( oldVersion == 2 )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Wiping cache";
|
||||
|
||||
performWipe( m_cacheBaseDir );
|
||||
|
||||
performWipe( m_cacheBaseDir + "/InfoSystemCache/" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::pruneTimerFired()
|
||||
{
|
||||
|
@ -55,16 +55,12 @@ private slots:
|
||||
|
||||
private:
|
||||
void notInCache( QObject *receiver, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void doUpgrade( uint oldVersion, uint newVersion );
|
||||
void performWipe( QString directory );
|
||||
const QString criteriaMd5( const Tomahawk::InfoSystem::InfoStringHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const;
|
||||
|
||||
QString m_cacheBaseDir;
|
||||
QHash< InfoType, QHash< QString, QString > > m_fileLocationCache;
|
||||
QTimer m_pruneTimer;
|
||||
QCache< QString, QVariant > m_dataCache;
|
||||
|
||||
uint m_cacheVersion;
|
||||
};
|
||||
|
||||
} //namespace InfoSystem
|
||||
|
Loading…
x
Reference in New Issue
Block a user