xapian revert the needToRebuildBTreeIndex to needToRebuildIndex

This commit is contained in:
Xiao YiFang 2022-10-08 21:16:15 +08:00
parent c930687055
commit df0622d216
5 changed files with 3 additions and 50 deletions

View file

@ -589,51 +589,6 @@ string getFtsSuffix(){
#endif
}
bool needToRebuildBTreeIndex( vector< string > const & dictionaryFiles,
string const & indexFile ) noexcept
{
unsigned long lastModified = 0;
for( std::vector< string >::const_iterator i = dictionaryFiles.begin();
i != dictionaryFiles.end(); ++i )
{
QString name = FsEncoding::decode( i->c_str() );
QFileInfo fileInfo( name );
unsigned long ts;
if( fileInfo.isDir() )
continue;
if( name.toLower().endsWith( ".zip" ) )
{
ZipFile::SplitZipFile zf( name );
if( !zf.exists() )
return true;
ts = zf.lastModified().toSecsSinceEpoch();
}
else
{
if ( !fileInfo.exists() )
return true;
ts = fileInfo.lastModified().toSecsSinceEpoch();
}
if ( ts > lastModified )
lastModified = ts;
}
QDir d(FsEncoding::decode( indexFile.c_str() ));
if(d.exists()){
d.removeRecursively();
}
QFileInfo fileInfo( FsEncoding::decode( indexFile.c_str() ) );
if ( !fileInfo.exists() )
return true;
return fileInfo.lastModified().toSecsSinceEpoch() < lastModified;
}
QString generateRandomDictionaryId()
{
return QString(

View file

@ -497,8 +497,6 @@ string makeDictionaryId( vector< string > const & dictionaryFiles ) noexcept;
bool needToRebuildIndex( vector< string > const & dictionaryFiles,
string const & indexFile ) noexcept;
bool needToRebuildBTreeIndex( vector< string > const & dictionaryFiles,
string const & indexFile ) noexcept;
string getFtsSuffix();
/// Returns a random dictionary id useful for interactively created
/// dictionaries.

2
dsl.cc
View file

@ -1943,7 +1943,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
string indexFile = indicesDir + dictId;
if ( Dictionary::needToRebuildBTreeIndex( dictFiles, indexFile ) ||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) ||
indexIsOldOrBad( indexFile, zipFileName.size() ) )
{
DslScanner scanner( *i );

2
mdx.cc
View file

@ -1401,7 +1401,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
string dictId = Dictionary::makeDictionaryId( dictFiles );
string indexFile = indicesDir + dictId;
if ( Dictionary::needToRebuildBTreeIndex( dictFiles, indexFile ) ||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) ||
indexIsOldOrBad( dictFiles, indexFile ) )
{
// Building the index

2
zim.cc
View file

@ -1545,7 +1545,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
try
{
if ( Dictionary::needToRebuildBTreeIndex( dictFiles, indexFile ) ||
if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) ||
indexIsOldOrBad( indexFile ) )
{
gdDebug( "Zim: Building the index for dictionary: %s\n", i->c_str() );