diff --git a/src/libtomahawk/TomahawkSettings.cpp b/src/libtomahawk/TomahawkSettings.cpp index 86bfaceaf..0965a05ff 100644 --- a/src/libtomahawk/TomahawkSettings.cpp +++ b/src/libtomahawk/TomahawkSettings.cpp @@ -23,6 +23,7 @@ #include "collection/Collection.h" #include "database/DatabaseCommand_UpdateSearchIndex.h" #include "database/Database.h" +#include "database/fuzzyindex/DatabaseFuzzyIndex.h" #include "infosystem/InfoSystemCache.h" #include "playlist/PlaylistUpdaterInterface.h" #include "utils/Logger.h" @@ -312,6 +313,7 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion ) else if ( oldVersion == 4 || oldVersion == 5 ) { // 0.3.0 contained a bug which prevent indexing local files. Force a reindex. + Tomahawk::DatabaseFuzzyIndex::wipeIndex(); updateIndex(); } else if ( oldVersion == 6 ) @@ -676,10 +678,11 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion ) else if ( oldVersion == 15 ) { // 0.8.0 switches to Lucene++. Force a reindex. - // updateIndex(); + // (obsoleted by version 16 update) } else if ( oldVersion == 16 ) { + Tomahawk::DatabaseFuzzyIndex::wipeIndex(); updateIndex(); } } @@ -1534,8 +1537,8 @@ TomahawkSettings::updateIndex() return; } - tDebug() << Q_FUNC_INFO << "Wiping index."; -// Database::instance()->wipeIndex(); + tDebug() << Q_FUNC_INFO << "Updating fuzzy index."; + Tomahawk::DatabaseCommand* cmd = new Tomahawk::DatabaseCommand_UpdateSearchIndex(); Database::instance()->enqueue( QSharedPointer( cmd ) ); } diff --git a/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.cpp b/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.cpp index 87fd9686b..dc35e3d43 100644 --- a/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.cpp +++ b/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.cpp @@ -20,11 +20,17 @@ #include "database/DatabaseImpl.h" #include "database/Database.h" +#include "utils/TomahawkUtils.h" + +#include + namespace Tomahawk { +static QString s_indexPathName = "tomahawk.lucene"; + DatabaseFuzzyIndex::DatabaseFuzzyIndex( QObject* parent, bool wipe ) - : FuzzyIndex( parent, "tomahawk.lucene", wipe ) + : FuzzyIndex( parent, s_indexPathName, wipe ) { } @@ -36,4 +42,11 @@ DatabaseFuzzyIndex::updateIndex() Tomahawk::Database::instance()->enqueue( Tomahawk::dbcmd_ptr( cmd ) ); } + +void +DatabaseFuzzyIndex::wipeIndex() +{ + TomahawkUtils::removeDirectory( TomahawkUtils::appDataDir().absoluteFilePath( s_indexPathName ) ); +} + } // namespace Tomahawk diff --git a/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.h b/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.h index ef5f891fe..6c6e0ba53 100644 --- a/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.h +++ b/src/libtomahawk/database/fuzzyindex/DatabaseFuzzyIndex.h @@ -29,6 +29,7 @@ public: explicit DatabaseFuzzyIndex( QObject* parent, bool wipe = false ); virtual void updateIndex(); + static void wipeIndex(); }; } // namespace Tomahawk