日志界面的备份名称优化

This commit is contained in:
zhaominyong 2022-03-09 10:27:29 +08:00
parent d74bad1b65
commit c4fef89cf8
7 changed files with 80 additions and 14 deletions

View File

@ -6,6 +6,7 @@
#include <sys/reboot.h>
#include "../common/utils.h"
#include "mymountproxy.h"
#include "parsebackuplist.h"
IMPLEMENT_DYNCREATE(DataRestoreProxy)
@ -61,6 +62,17 @@ bool DataRestoreProxy::checkEnvEx()
return false;
}
// 4、检测xml中的还原点是否还存在
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
xmlPath.replace("//", "/");
ParseBackupList parse(xmlPath);
m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid);
if (m_backupPoint.m_uuid.isEmpty()) {
qCritical("xml中还原点不存在");
emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR));
return false;
}
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
qDebug() << "DataRestoreProxy::checkEnvEx invoke end";
@ -128,7 +140,7 @@ void DataRestoreProxy::restoreData()
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
if (result) {
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName);
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName);
}
emit this->workResult(result);
});

View File

@ -42,10 +42,10 @@ bool DeleteBackupProxy::deleteXmlBackupPoint()
xmlPath.replace("//", "/");
ParseBackupList parse(xmlPath);
// 查询节点
ParseBackupList::BackupPoint backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid);
if ( int(BackupType::BACKUP_DATA) != backupPoint.m_type
&& int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type) {
m_backupWrapper.m_type = backupPoint.m_type;
m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid);
if ( int(BackupType::BACKUP_DATA) != m_backupPoint.m_type
&& int(BackupType::INC_BACKUP_DATA) != m_backupPoint.m_type) {
m_backupWrapper.m_type = m_backupPoint.m_type;
}
// 删除节点
@ -79,9 +79,9 @@ void DeleteBackupProxy::deleteBackupPointDir()
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
if ( int(BackupType::BACKUP_DATA) == m_backupWrapper.m_type
|| int(BackupType::INC_BACKUP_DATA) == m_backupWrapper.m_type) {
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName);
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName);
} else {
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName);
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName);
}
}

View File

@ -61,6 +61,17 @@ bool SystemRestoreProxy::checkEnvEx()
return false;
}
// 4、检测xml中的还原点是否还存在
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
xmlPath.replace("//", "/");
ParseBackupList parse(xmlPath);
m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid);
if (m_backupPoint.m_uuid.isEmpty()) {
qCritical("xml中还原点不存在");
emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR));
return false;
}
m_curUuid = m_backupWrapper.m_uuid;
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
@ -337,7 +348,7 @@ void SystemRestoreProxy::restoreSystem()
if (result) {
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName);
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName);
Utils::updateSyncFile();
QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC;

View File

@ -60,6 +60,17 @@ bool UDiskDataRestoreProxy::checkEnvEx()
return false;
}
// 4、检测xml中的还原点是否还存在
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
xmlPath.replace("//", "/");
ParseBackupList parse(xmlPath);
m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid);
if (m_backupPoint.m_uuid.isEmpty()) {
qCritical("xml中还原点不存在");
emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR));
return false;
}
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
qDebug() << "UDiskDataRestoreProxy::checkEnvEx invoke end";
@ -129,7 +140,7 @@ void UDiskDataRestoreProxy::restoreData()
m_isFinished = true;
if (result) {
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName);
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName);
}
emit this->workResult(result);
});

View File

@ -63,6 +63,17 @@ bool UDiskSystemRestoreProxy::checkEnvEx()
return false;
}
// 4、检测xml中的还原点是否还存在
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
xmlPath.replace("//", "/");
ParseBackupList parse(xmlPath);
m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid);
if (m_backupPoint.m_uuid.isEmpty()) {
qCritical("xml中还原点不存在");
emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR));
return false;
}
m_curUuid = m_backupWrapper.m_uuid;
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
@ -346,6 +357,9 @@ bool UDiskSystemRestoreProxy::doPrepare()
*/
void UDiskSystemRestoreProxy::restoreSystem()
{
// 停止安全防护
QProcess::execute("systemctl stop kysec-init.service");
QString destPath = Utils::getSysRootPath();
QStringList args;
@ -367,7 +381,7 @@ void UDiskSystemRestoreProxy::restoreSystem()
if (result) {
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName);
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName);
Utils::updateSyncFile();
QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC;

View File

@ -944,11 +944,11 @@ QList<BackupWrapper> Utils::getBackupLogList()
if (FACTORY_BACKUP_UUID == record.m_uuid) {
record.m_backupName = QObject::tr("Factory Backup");
}
// else if (AUTO_BACKUP_UUID == record.m_uuid) {
// record.m_backupName = QObject::tr("Auto Backup");
// }
else if (AUTO_BACKUP_UUID == record.m_uuid) {
record.m_backupName = QObject::tr("Auto Backup");
}
else {
record.m_backupName = record.m_uuid;
record.m_backupName = record.m_time;
}
}
@ -1131,6 +1131,18 @@ void Utils::deleteBackupUniqueRecord(const QString& backupName)
udisk_unique_settings.remove(backupName);
}
QMap<QString, QString> Utils::getBackupUuidNameMap()
{
QString backupUniqueSetting = Utils::getSysRootPath() + UDISK_UNIQUE_SETTINGS;
backupUniqueSetting.replace("//", "/");
QSettings udisk_unique_settings(backupUniqueSetting, QSettings::IniFormat);
QStringList groups = udisk_unique_settings.childGroups();
QMap<QString, QString> result;
return result;
}
/**
* @brief
* @return

View File

@ -293,6 +293,12 @@ public:
*/
static void deleteBackupUniqueRecord(const QString& backupName);
/**
* @brief Uuid-BackupName键值对
* @return Uuid-BackupName键值对
*/
static QMap<QString, QString> getBackupUuidNameMap();
/**
* @brief
* @return