diff --git a/UpdatePTUDevCtrl/worker.cpp b/UpdatePTUDevCtrl/worker.cpp index b6c6032..dd6a22d 100644 --- a/UpdatePTUDevCtrl/worker.cpp +++ b/UpdatePTUDevCtrl/worker.cpp @@ -864,7 +864,24 @@ bool Worker::computeFilesToDownload() { return (m_filesToDownload.size() > 0); } + +bool Worker::cleanUpOpkgCache() { + bool removedFiles = true; + QDir dir("/var/cache/opkg"); + if (dir.exists()) { + dir.setNameFilters(QStringList() << ".gz" << ".ipk"); + dir.setFilter(QDir::Files); + foreach(QString dirFile, dir.entryList()) { + removedFiles &= dir.remove(dirFile); + } + } + return removedFiles; +} + bool Worker::execOpkgCommands() { + if (!cleanUpOpkgCache()) { + CONSOLE() << "INFO: some cached opkg files not removed"; + } for (int i = 0; i < m_filesToUpdate.size(); ++i) { QString const fName = m_filesToUpdate.at(i); if (fName.contains("opkg_commands", Qt::CaseInsensitive)) { diff --git a/UpdatePTUDevCtrl/worker.h b/UpdatePTUDevCtrl/worker.h index 231db52..d30984d 100644 --- a/UpdatePTUDevCtrl/worker.h +++ b/UpdatePTUDevCtrl/worker.h @@ -193,6 +193,7 @@ class Worker : public QThread{ QString m_apismVersion; bool executeOpkgCommand(QString opkgCommand); + bool cleanUpOpkgCache(); QString getOsVersion() const; QString getATBQTVersion() const; QString getATBUpdateToolVersion() const;