测试有问题,再次修改

This commit is contained in:
赵民勇 2022-09-13 14:56:06 +08:00
parent a2ea352c18
commit 5e89b1eec1
1 changed files with 14 additions and 3 deletions

View File

@ -394,8 +394,12 @@ void SystemRestoreProxy::restoreSystem()
QStringList SystemRestoreProxy::getBackupPointUsers()
{
// 根据备份点里的/home或/data/home的子目录进行统计
QStringList users = getBackupPointUsers(m_backupPath + "/home");
users.append(getBackupPointUsers(m_backupPath + "/data/home"));
QString homePath = m_backupPath + "/home";
homePath.replace("//","/");
QStringList users = getBackupPointUsers(homePath);
QString dataHomePath = m_backupPath + "/data/home";
dataHomePath.replace("//","/");
users.append(getBackupPointUsers(dataHomePath));
return users;
}
@ -416,9 +420,12 @@ QStringList SystemRestoreProxy::getBackupPointUsers(const QString& path)
*/
void SystemRestoreProxy::removeHome(const QString& path)
{
qDebug() << "SystemRestoreProxy::removeHome invoke begin";
QDir dir(path);
if (dir.exists()) {
QStringList retainUsers = getBackupPointUsers(m_backupPath + path);
QStringList retainUsers = getBackupPointUsers();
qDebug() << retainUsers;
bool needRm = false;
QString subcmd("rm -rf ");
@ -426,6 +433,8 @@ void SystemRestoreProxy::removeHome(const QString& path)
QStringList list = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs);
for (const QString& item : list) {
// 出厂备份里面的/home/oem等保留
if (item == "oem")
continue ;
if (retainUsers.contains(item))
continue ;
@ -450,4 +459,6 @@ void SystemRestoreProxy::removeHome(const QString& path)
QProcess::execute(cmd);
}
}
qDebug() << "SystemRestoreProxy::removeHome invoke end";
}