fix: epwing rebuild issue (#1094)

* fix: epwing rebuild issue

* [autofix.ci] apply automated fixes

* fix: pro project file

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
xiaoyifang 2023-08-27 10:15:21 +08:00 committed by GitHub
parent 78ef410b3b
commit 98af55557e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 22 deletions

View file

@ -601,8 +601,7 @@ win32{
RESOURCES += resources.qrc \
src/scripts/scripts.qrc \
icons/flags.qrc \
src/stylesheets/css.qrc \
src/ui/resources.qrc
src/stylesheets/css.qrc
#EXTRA_TRANSLATIONS += thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts
TRANSLATIONS += $$files(locale/*.ts)

View file

@ -1175,6 +1175,10 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
dict.setSubBook( sb );
dir = QString::fromStdString( mainDirectory ) + Utils::Fs::separator() + dict.getCurrentSubBookDirectory();
QDir _dir( dir );
if ( !_dir.exists() ) {
continue;
}
Epwing::Book::EpwingBook::collectFilenames( dir, dictFiles );
@ -1185,7 +1189,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
dictFiles.push_back( fontSubName.toStdString() );
else {
//to make the subbook in different index.
dictFiles.push_back( QString::number( sb ).toStdString() );
auto virtual_file = QString::fromStdString( mainDirectory ) + QDir::separator() + QString::number( sb );
dictFiles.push_back( virtual_file.toStdString() );
}
// Check if we need to rebuid the index

View file

@ -294,24 +294,6 @@ void loadDictionaries( QWidget * parent,
}
}
QDir indexDir( Config::getIndexDir() );
QStringList allIdxFiles = indexDir.entryList( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks );
for ( const auto & file : allIdxFiles ) {
if ( file.size() >= 32 && ids.find( file.left( 32 ).toStdString() ) == ids.end() ) {
if ( QFile::exists( file ) ) {
indexDir.remove( file );
}
else {
// must be folder .
auto dirPath = Utils::Path::combine( Config::getIndexDir(), file );
QDir t( dirPath );
t.removeRecursively();
}
}
}
// Run deferred inits
if ( doDeferredInit_ )