diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 024097c5..5fd3234a 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -85,15 +85,11 @@ MainWindow::MainWindow(QWidget *parent) HGChar logFilePath[512]; HGBase_GetLogFilePath(logFilePath, 512); - deleteFile(QString::fromStdString(getStdString(logFilePath))); + deleteOverdueLogFile(QString::fromStdString(getStdString(logFilePath))); HGChar cfgFilePath[512]; HGBase_GetConfigPath(cfgFilePath, 512); - deleteFile(QString::fromStdString(getStdString(cfgFilePath))); - - HGChar upgradeDpkgPath[512]; - HGBase_GetTmpPath(upgradeDpkgPath, 512); - deleteFile(QString::fromStdString(getStdString(upgradeDpkgPath))); + deleteUpgradePkg(QString::fromStdString(getStdString(cfgFilePath))); #if defined(OEM_HANWANG) this->setWindowIcon(QIcon(":images/image_rsc/logo/Hanvon_logo1.ico")); @@ -3947,9 +3943,9 @@ QString MainWindow::getLogInfo(HGResult ret) return str; } -void MainWindow::deleteFile(QString filePath) +void MainWindow::deleteOverdueLogFile(const QString& logFilePath) { - QDir dir(filePath); + QDir dir(logFilePath); if(!dir.exists()) { return; @@ -3977,7 +3973,30 @@ void MainWindow::deleteFile(QString filePath) HGBase_DeleteFile(info.absoluteFilePath().toStdString().c_str()); } } - else if(suffix == "exe") + } +} + +void MainWindow::deleteUpgradePkg(const QString &cfgFilePath) +{ + QDir dir(cfgFilePath); + if(!dir.exists()) + { + return; + } + dir.setFilter(QDir::Files | QDir::NoSymLinks); + QFileInfoList list = dir.entryInfoList(); + + int count = list.count(); + if(count <= 0) + { + return; + } + + for(int i=0; i < count; i++) + { + QFileInfo info = list.at(i); + QString suffix = info.suffix(); + if(suffix == "exe") { HGBase_DeleteFile(info.absoluteFilePath().toStdString().c_str()); } @@ -4087,7 +4106,7 @@ void MainWindow::on_actionact_update_triggered() HGBase_GetFileSuffix(url.toStdString().c_str(), suffix, 64); HGChar savePath[512]; - HGBase_GetTmpPath(savePath, 512); + HGBase_GetConfigPath(savePath, 512); HGBase_CreateDir(savePath); HGChar fileName[128]; diff --git a/app/scanner/mainwindow.h b/app/scanner/mainwindow.h index 93bcda6e..e1908110 100644 --- a/app/scanner/mainwindow.h +++ b/app/scanner/mainwindow.h @@ -265,7 +265,8 @@ private: bool isLimitAccessFolder(QString filePath); static QString GetDevType(const QString& fwVersion); void upgradeFwAndLockDevice(); - void deleteFile(QString filePath); + void deleteOverdueLogFile(const QString& logFilePath); + void deleteUpgradePkg(const QString& cfgFilePath); private: Ui::MainWindow *ui; diff --git a/build-qt/HGSolution/HGScanner/HGScanner.pro b/build-qt/HGSolution/HGScanner/HGScanner.pro index d95273f8..d133a36c 100644 --- a/build-qt/HGSolution/HGScanner/HGScanner.pro +++ b/build-qt/HGSolution/HGScanner/HGScanner.pro @@ -236,7 +236,6 @@ HEADERS += \ ../../../app/scanner/widget_statusbar.h \ ../../../app/scanner/dialog_admin.h \ ../../../app/scanner/dialog_log.h \ - ../../../app/scanner/config.h \ ../../../app/scanner/cfg/gb_json.h \ ../../../app/scanner/cfg/cJSON.h \ ../../../app/scanner/HGImgThumb.h \