mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 09:34:53 +02:00
Get rid of InfoSystemCache version
This commit is contained in:
@@ -43,24 +43,8 @@ namespace InfoSystem
|
|||||||
InfoSystemCache::InfoSystemCache( QObject* parent )
|
InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_cacheBaseDir( TomahawkSettings::instance()->storageCacheLocation() + "/InfoSystemCache/" )
|
, m_cacheBaseDir( TomahawkSettings::instance()->storageCacheLocation() + "/InfoSystemCache/" )
|
||||||
, m_cacheVersion( 3 )
|
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
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.setInterval( 300000 );
|
||||||
m_pruneTimer.setSingleShot( false );
|
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
|
void
|
||||||
InfoSystemCache::pruneTimerFired()
|
InfoSystemCache::pruneTimerFired()
|
||||||
{
|
{
|
||||||
|
@@ -55,16 +55,12 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void notInCache( QObject *receiver, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
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;
|
const QString criteriaMd5( const Tomahawk::InfoSystem::InfoStringHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const;
|
||||||
|
|
||||||
QString m_cacheBaseDir;
|
QString m_cacheBaseDir;
|
||||||
QHash< InfoType, QHash< QString, QString > > m_fileLocationCache;
|
QHash< InfoType, QHash< QString, QString > > m_fileLocationCache;
|
||||||
QTimer m_pruneTimer;
|
QTimer m_pruneTimer;
|
||||||
QCache< QString, QVariant > m_dataCache;
|
QCache< QString, QVariant > m_dataCache;
|
||||||
|
|
||||||
uint m_cacheVersion;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace InfoSystem
|
} //namespace InfoSystem
|
||||||
|
Reference in New Issue
Block a user