ソースを参照

Embedded : make sure we clean up update directories when needed

The update cache was remaining there, we didn't clean up directories
LongChair 7 年 前
コミット
c2f1530238
1 ファイル変更18 行追加0 行削除
  1. 18 0
      src/system/OEUpdateManager.cpp

+ 18 - 0
src/system/OEUpdateManager.cpp

@@ -25,6 +25,19 @@ void OEUpdateManager::doUpdate(const QString& version)
 
   QStringList updateFiles = packageDir.entryList(QStringList( "*.tar"), QDir::Files, QDir::Time);
 
+  // make sure we remove all the eventually remaining downloads
+  QDir rootDir(GetPath("", "", false));
+
+  foreach(auto updateDir, rootDir.entryList(QStringList("*"), QDir::Dirs | QDir::NoDotAndDotDot))
+  {
+      QDir checkDir(rootDir.absolutePath() + updateDir);
+      if (checkDir != QDir(GetPath("", version, false)))
+      {
+          if (!checkDir.removeRecursively())
+              QLOG_ERROR() << "Failed to remove directory" << checkDir.path();
+      }
+  }
+
   if (updateFiles.size())
   {
     // copy the update files to /storage/.update
@@ -39,6 +52,11 @@ void OEUpdateManager::doUpdate(const QString& version)
       }
       else
       {
+        // remove the update package
+        QDir updateDir(GetPath("", version, false));
+        if (!updateDir.removeRecursively())
+            QLOG_ERROR() << "Failed to remove directory" << updateDir.path();
+
         // now reboot to do the update
         QLOG_DEBUG() << "Rebooting to apply system update " << destUpdatePath;
         QProcess::startDetached("reboot");