1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +02:00

Delete lucene directory on upgrade to work-around Lucene++ (<3.0.6) crashes.

This commit is contained in:
Christian Muehlhaeuser
2014-11-02 19:42:15 +01:00
parent 53661b05d3
commit 6109158ea6
3 changed files with 21 additions and 4 deletions

View File

@@ -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<Tomahawk::DatabaseCommand>( cmd ) );
}

View File

@@ -20,11 +20,17 @@
#include "database/DatabaseImpl.h"
#include "database/Database.h"
#include "utils/TomahawkUtils.h"
#include <QDir>
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

View File

@@ -29,6 +29,7 @@ public:
explicit DatabaseFuzzyIndex( QObject* parent, bool wipe = false );
virtual void updateIndex();
static void wipeIndex();
};
} // namespace Tomahawk