mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-25 06:51:13 +02:00
use existing TomahawkUtils function to remove directory
This commit is contained in:
@@ -25,10 +25,6 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
|
||||||
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
|
|
||||||
#include "utils/TomahawkCache.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
@@ -49,7 +45,7 @@ InfoSystemCache::InfoSystemCache( QObject* parent )
|
|||||||
if ( TomahawkSettings::instance()->infoSystemCacheVersion() < INFOSYSTEM_CACHE_VERSION )
|
if ( TomahawkSettings::instance()->infoSystemCacheVersion() < INFOSYSTEM_CACHE_VERSION )
|
||||||
{
|
{
|
||||||
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
|
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
|
||||||
TomahawkUtils::Cache::instance()->removeDirectoryRecursively( m_cacheBaseDir );
|
TomahawkUtils::removeDirectory( m_cacheBaseDir );
|
||||||
#else
|
#else
|
||||||
QDir(m_cacheBaseDir)::removeRecursively();
|
QDir(m_cacheBaseDir)::removeRecursively();
|
||||||
#endif
|
#endif
|
||||||
|
@@ -48,7 +48,7 @@ Cache::Cache()
|
|||||||
if ( TomahawkSettings::instance()->genericCacheVersion() < CACHE_VERSION )
|
if ( TomahawkSettings::instance()->genericCacheVersion() < CACHE_VERSION )
|
||||||
{
|
{
|
||||||
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
|
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
|
||||||
removeDirectoryRecursively( m_cacheBaseDir );
|
TomahawkUtils::removeDirectory( m_cacheBaseDir );
|
||||||
#else
|
#else
|
||||||
QDir( m_cacheBaseDir )::removeRecursively();
|
QDir( m_cacheBaseDir )::removeRecursively();
|
||||||
#endif
|
#endif
|
||||||
@@ -126,33 +126,6 @@ Cache::getData( const QString& identifier, const QString& key )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
|
|
||||||
bool
|
|
||||||
Cache::removeDirectoryRecursively(const QString& dirName)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
|
|
||||||
QDir dir(dirName);
|
|
||||||
if (dir.exists(dirName)) {
|
|
||||||
foreach( QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst) ) {
|
|
||||||
if (info.isDir()) {
|
|
||||||
result = removeDirectoryRecursively(info.absoluteFilePath());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = QFile::remove(info.absoluteFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = dir.rmdir(dirName);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Cache::putData( const QString& identifier, qint64 maxAge, const QString& key, const QVariant& value )
|
Cache::putData( const QString& identifier, qint64 maxAge, const QString& key, const QVariant& value )
|
||||||
{
|
{
|
||||||
|
@@ -81,15 +81,6 @@ public:
|
|||||||
* @return the data, if found, if not found an invalid QVariant is returned.
|
* @return the data, if found, if not found an invalid QVariant is returned.
|
||||||
*/
|
*/
|
||||||
QVariant getData( const QString& identifier, const QString& key );
|
QVariant getData( const QString& identifier, const QString& key );
|
||||||
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
|
|
||||||
/**
|
|
||||||
* Recursively deletes all files & directories in a folder
|
|
||||||
* Only needed in Qt4
|
|
||||||
* @param dirName the directory which should be deleted
|
|
||||||
* @return if the removal was successfull or not
|
|
||||||
*/
|
|
||||||
bool removeDirectoryRecursively( const QString& dirName );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void pruneTimerFired();
|
void pruneTimerFired();
|
||||||
|
Reference in New Issue
Block a user