瀏覽代碼

Make sure to remove old update pacakges

Tobias Hieta 9 年之前
父節點
當前提交
6f04b9cebe
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/system/UpdateManager.cpp

+ 9 - 0
src/system/UpdateManager.cpp

@@ -55,11 +55,20 @@ QString UpdateManager::HaveUpdate()
     // check if this version has been applied
     QString readyFile(GetPath("_readyToApply", dir, false));
     QLOG_DEBUG() << "Checking for:" << readyFile;
+
+    QDir packageDir(GetPath("packages", dir, false));
+
     if (QFile::exists(readyFile))
     {
       QLOG_DEBUG() << dir << "is not applied";
       return dir;
     }
+    else if (packageDir.exists())
+    {
+      QLOG_DEBUG() << "Removing old update packages in dir:" << dir;
+      if (!packageDir.removeRecursively())
+        QLOG_WARN() << "Failed to remove old update packages in dir:" << dir;
+    }
   }
 
   QLOG_DEBUG() << "No valid/applicable update found.";