mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
opt: remove outdated fulltext temp index (#1717)
* opt: remove outdated fulltext temp index * opt: remove outdated fulltext temp index
This commit is contained in:
parent
ec63fa550d
commit
b0bea92106
|
@ -1216,6 +1216,32 @@ void MainWindow::commitData()
|
||||||
if ( d.exists() ) {
|
if ( d.exists() ) {
|
||||||
d.removeRecursively();
|
d.removeRecursively();
|
||||||
}
|
}
|
||||||
|
//temp dir
|
||||||
|
QDir dtemp( filePath + "_FTS_x_temp" );
|
||||||
|
if ( dtemp.exists() ) {
|
||||||
|
dtemp.removeRecursively();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//remove temp directories.
|
||||||
|
QFileInfoList const dirs = dir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
|
||||||
|
|
||||||
|
for ( auto & file : dirs ) {
|
||||||
|
QString const fileName = file.fileName();
|
||||||
|
|
||||||
|
if ( !fileName.endsWith( "_temp" ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const QFileInfo info( fileName );
|
||||||
|
const QDateTime lastModified = info.lastModified();
|
||||||
|
|
||||||
|
//if the temp directory has not been modified within 7 days,remove the temp directory.
|
||||||
|
if ( lastModified.addDays( 7 ) > QDateTime::currentDateTime() ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QDir d( fileName );
|
||||||
|
d.removeRecursively();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue