diff --git a/src/dict/sounddir.cc b/src/dict/sounddir.cc index f0f3b9147..a61852cd8 100644 --- a/src/dict/sounddir.cc +++ b/src/dict/sounddir.cc @@ -17,6 +17,7 @@ #include #include #include +#include namespace SoundDir { @@ -438,7 +439,24 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::SoundDirs const & string indexFile = indicesDir + dictId; - if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) { + // Check if the soundDir and its subdirs' modification date changed, that means the user modified the sound files inside + + bool soundDirModified = false; + { + QDateTime indexFileModifyTime = QFileInfo( QString::fromStdString( indexFile ) ).lastModified(); + QDirIterator it( dir.path(), + QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks, + QDirIterator::Subdirectories ); + while ( it.hasNext() ) { + it.next(); + if ( it.fileInfo().lastModified() > indexFileModifyTime ) { + soundDirModified = true; + break; + } + } + } + + if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) || soundDirModified ) { // Building the index qDebug() << "Sounds: Building the index for directory: " << soundDir.path;