mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Bump cache version; put back in its proper place, and put in a better place in headless
This commit is contained in:
@@ -44,7 +44,7 @@ TomahawkSettingsGui::~TomahawkSettingsGui()
|
|||||||
QString
|
QString
|
||||||
TomahawkSettingsGui::storageCacheLocation() const
|
TomahawkSettingsGui::storageCacheLocation() const
|
||||||
{
|
{
|
||||||
return QDesktopServices::storageLocation( QDesktopServices::CacheLocation ) + "/InfoSystemCache/";
|
return QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ 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( 2 )
|
, m_cacheVersion( 3 )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
TomahawkSettings *s = TomahawkSettings::instance();
|
TomahawkSettings *s = TomahawkSettings::instance();
|
||||||
@@ -73,6 +73,27 @@ InfoSystemCache::~InfoSystemCache()
|
|||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
void
|
||||||
InfoSystemCache::doUpgrade( uint oldVersion, uint newVersion )
|
InfoSystemCache::doUpgrade( uint oldVersion, uint newVersion )
|
||||||
{
|
{
|
||||||
@@ -82,17 +103,16 @@ InfoSystemCache::doUpgrade( uint oldVersion, uint newVersion )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Wiping cache";
|
qDebug() << Q_FUNC_INFO << "Wiping cache";
|
||||||
|
|
||||||
for ( int i = InfoNoInfo; i <= InfoLastInfo; i++ )
|
performWipe( m_cacheBaseDir );
|
||||||
{
|
}
|
||||||
InfoType type = (InfoType)(i);
|
|
||||||
const QString cacheDirName = m_cacheBaseDir + QString::number( (int)type );
|
if ( oldVersion == 2 )
|
||||||
QFileInfoList fileList = QDir( cacheDirName ).entryInfoList( QDir::Files | QDir::NoDotAndDotDot );
|
{
|
||||||
foreach ( QFileInfo file, fileList )
|
qDebug() << Q_FUNC_INFO << "Wiping cache";
|
||||||
{
|
|
||||||
if ( !QFile::remove( file.canonicalFilePath() ) )
|
performWipe( m_cacheBaseDir );
|
||||||
tLog() << "During upgrade, failed to remove cache file " << file.canonicalFilePath();
|
|
||||||
}
|
performWipe( m_cacheBaseDir + "/InfoSystemCache/" );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,6 +56,7 @@ 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 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;
|
||||||
|
@@ -435,7 +435,7 @@ TomahawkSettings::setInfoSystemCacheVersion( uint version )
|
|||||||
uint
|
uint
|
||||||
TomahawkSettings::infoSystemCacheVersion() const
|
TomahawkSettings::infoSystemCacheVersion() const
|
||||||
{
|
{
|
||||||
return value( "infosystemcacheversion", 0 ).toUInt();
|
return value( "infosystemcacheversion", 3 ).toUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user