xapian remove obsolete ftx index

This commit is contained in:
Xiao YiFang 2022-10-07 17:08:10 +08:00
parent 46b8969666
commit 1ad358bb84
4 changed files with 30 additions and 11 deletions

View file

@ -428,6 +428,7 @@ SOURCES += folding.cc \
btreeidx.cc \ btreeidx.cc \
stardict.cc \ stardict.cc \
chunkedstorage.cc \ chunkedstorage.cc \
utils.cc \
weburlrequestinterceptor.cpp \ weburlrequestinterceptor.cpp \
xdxf2html.cc \ xdxf2html.cc \
iconv.cc \ iconv.cc \

View file

@ -397,19 +397,24 @@ void loadDictionaries( QWidget * parent, bool showInitially,
QDir indexDir( Config::getIndexDir() ); QDir indexDir( Config::getIndexDir() );
QStringList allIdxFiles = indexDir.entryList( QDir::Files ); QStringList allIdxFiles = indexDir.entryList( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks );
for( QStringList::const_iterator i = allIdxFiles.constBegin(); for( QStringList::const_iterator i = allIdxFiles.constBegin(); i != allIdxFiles.constEnd(); ++i )
i != allIdxFiles.constEnd(); ++i )
{ {
if ( ids.find( FsEncoding::encode( *i ) ) == ids.end() if( i->size() >= 32 && ids.find( FsEncoding::encode( i->left( 32 ) ) ) == ids.end() )
&& i->size() == 32 ) {
indexDir.remove( *i ); if( QFile::exists( *i ) )
else {
if ( i->endsWith( "_FTS" ) indexDir.remove( *i );
&& i->size() == 36 }
&& ids.find( FsEncoding::encode( i->left( 32 ) ) ) == ids.end() ) else
indexDir.remove( *i ); {
// must be folder .
auto dirPath = Utils::Path::combine( Config::getIndexDir(), *i );
QDir t( dirPath );
t.removeRecursively();
}
}
} }
// Run deferred inits // Run deferred inits

7
utils.cc Normal file
View file

@ -0,0 +1,7 @@
#include "utils.hh"
#include <QDir>
QString Utils::Path::combine(const QString& path1, const QString& path2)
{
return QDir::cleanPath(path1 + QDir::separator() + path2);
}

View file

@ -274,6 +274,10 @@ inline bool isAudioUrl( QUrl const & url )
} }
namespace Path{
QString combine(const QString& path1, const QString& path2);
}
} }
namespace namespace
@ -313,4 +317,6 @@ inline QString getHostBaseFromUrl( QUrl const & url )
} }
} }
#endif // UTILS_HH #endif // UTILS_HH