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 \
stardict.cc \
chunkedstorage.cc \
utils.cc \
weburlrequestinterceptor.cpp \
xdxf2html.cc \
iconv.cc \

View file

@ -397,19 +397,24 @@ void loadDictionaries( QWidget * parent, bool showInitially,
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();
i != allIdxFiles.constEnd(); ++i )
for( QStringList::const_iterator i = allIdxFiles.constBegin(); i != allIdxFiles.constEnd(); ++i )
{
if ( ids.find( FsEncoding::encode( *i ) ) == ids.end()
&& i->size() == 32 )
indexDir.remove( *i );
else
if ( i->endsWith( "_FTS" )
&& i->size() == 36
&& ids.find( FsEncoding::encode( i->left( 32 ) ) ) == ids.end() )
indexDir.remove( *i );
if( i->size() >= 32 && ids.find( FsEncoding::encode( i->left( 32 ) ) ) == ids.end() )
{
if( QFile::exists( *i ) )
{
indexDir.remove( *i );
}
else
{
// must be folder .
auto dirPath = Utils::Path::combine( Config::getIndexDir(), *i );
QDir t( dirPath );
t.removeRecursively();
}
}
}
// 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
@ -313,4 +317,6 @@ inline QString getHostBaseFromUrl( QUrl const & url )
}
}
#endif // UTILS_HH