From 98af55557ece07a00b80954b5c7e7df837cda018 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Sun, 27 Aug 2023 10:15:21 +0800 Subject: [PATCH] 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> --- goldendict.pro | 3 +-- src/dict/epwing.cc | 9 +++++++-- src/dict/loaddictionaries.cc | 18 ------------------ 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/goldendict.pro b/goldendict.pro index be58c517..c1ce0ab8 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -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) diff --git a/src/dict/epwing.cc b/src/dict/epwing.cc index 50f1a473..b4856720 100644 --- a/src/dict/epwing.cc +++ b/src/dict/epwing.cc @@ -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 @@ -1275,4 +1280,4 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f } // namespace Epwing -#endif \ No newline at end of file +#endif diff --git a/src/dict/loaddictionaries.cc b/src/dict/loaddictionaries.cc index 4c613ce7..cea5025b 100644 --- a/src/dict/loaddictionaries.cc +++ b/src/dict/loaddictionaries.cc @@ -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_ )