From 09d89c3663b59fb570ab2e3d45aa057b64082fe1 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 12 Jul 2012 07:22:20 +0200 Subject: [PATCH] * Use a RAMDirectory if we can't open the regular lucene index file. --- src/libtomahawk/database/FuzzyIndex.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/database/FuzzyIndex.cpp b/src/libtomahawk/database/FuzzyIndex.cpp index 64db5b690..176e55ccc 100644 --- a/src/libtomahawk/database/FuzzyIndex.cpp +++ b/src/libtomahawk/database/FuzzyIndex.cpp @@ -49,15 +49,24 @@ FuzzyIndex::FuzzyIndex( QObject* parent, bool wipe ) QByteArray path = m_lucenePath.toUtf8(); const char* cPath = path.constData(); + bool failed = false; tDebug() << "Opening Lucene directory:" << path; try { - m_luceneDir = FSDirectory::getDirectory( cPath ); m_analyzer = _CLNEW SimpleAnalyzer(); + m_luceneDir = FSDirectory::getDirectory( cPath ); } catch ( CLuceneError& error ) { tDebug() << "Caught CLucene error:" << error.what(); + failed = true; + } + + if ( failed ) + { + tDebug() << "Initializing RAM directory instead."; + + m_luceneDir = _CLNEW RAMDirectory(); wipe = true; }