opt: remove outdated fulltext temp index (#1717)

* opt: remove outdated fulltext temp index

* opt: remove outdated fulltext temp index
This commit is contained in:
xiaoyifang 2024-08-09 09:37:57 +08:00 committed by GitHub
parent ec63fa550d
commit b0bea92106
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1216,6 +1216,32 @@ void MainWindow::commitData()
if ( d.exists() ) {
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();
}
}