From b0bea921063184bfa5e5e1271b6b522e5753c705 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Fri, 9 Aug 2024 09:37:57 +0800 Subject: [PATCH] opt: remove outdated fulltext temp index (#1717) * opt: remove outdated fulltext temp index * opt: remove outdated fulltext temp index --- src/ui/mainwindow.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index c056a443..355e6d25 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -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(); } }