瀏覽代碼

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");