取消操作功能编码
This commit is contained in:
parent
b6eaa43087
commit
e8fa09f81f
|
@ -12,15 +12,23 @@ IMPLEMENT_DYNCREATE(DataBackupProxy)
|
||||||
|
|
||||||
DataBackupProxy::DataBackupProxy()
|
DataBackupProxy::DataBackupProxy()
|
||||||
{
|
{
|
||||||
|
m_isOnlyCheck = true;
|
||||||
m_bSuccess = false;
|
m_bSuccess = false;
|
||||||
|
m_isFinished = false;
|
||||||
m_p = nullptr;
|
m_p = nullptr;
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
|
m_calc = new CalcBackupSize(this);
|
||||||
|
|
||||||
|
connect(this, &DataBackupProxy::cancel, this, &DataBackupProxy::cancelEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBackupProxy::~DataBackupProxy()
|
DataBackupProxy::~DataBackupProxy()
|
||||||
{
|
{
|
||||||
delete m_p;
|
delete m_p;
|
||||||
m_p = nullptr;
|
m_p = nullptr;
|
||||||
|
|
||||||
|
delete m_calc;
|
||||||
|
m_calc = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,10 +50,10 @@ bool DataBackupProxy::checkEnvEx()
|
||||||
isIncBackup();
|
isIncBackup();
|
||||||
|
|
||||||
// 3、检测空间是否满足备份
|
// 3、检测空间是否满足备份
|
||||||
bool result = checkFreeCapacity();
|
calcSizeForBackup();
|
||||||
|
|
||||||
qDebug() << "DataBackupProxy::checkEnv invoke end";
|
qDebug() << "DataBackupProxy::checkEnv invoke end";
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,17 +62,52 @@ bool DataBackupProxy::checkEnvEx()
|
||||||
void DataBackupProxy::doWorkEx()
|
void DataBackupProxy::doWorkEx()
|
||||||
{
|
{
|
||||||
qDebug() << "DataBackupProxy::doWorkEx invoke begin";
|
qDebug() << "DataBackupProxy::doWorkEx invoke begin";
|
||||||
// 环境检测
|
|
||||||
if (!checkEnvEx())
|
|
||||||
return ;
|
|
||||||
|
|
||||||
// 开始备份
|
m_isOnlyCheck = false;
|
||||||
doBackup();
|
// 环境检测
|
||||||
|
checkEnvEx();
|
||||||
|
|
||||||
qDebug() << "DataBackupProxy::doWorkEx invoke end";
|
qDebug() << "DataBackupProxy::doWorkEx invoke end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 取消操作
|
||||||
|
*/
|
||||||
void DataBackupProxy::cancelEx()
|
void DataBackupProxy::cancelEx()
|
||||||
{}
|
{
|
||||||
|
m_bCancel = true;
|
||||||
|
if (!m_isFinished) {
|
||||||
|
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||||
|
|
||||||
|
if (m_calc)
|
||||||
|
m_calc->stop();
|
||||||
|
if (m_p)
|
||||||
|
m_p->stop();
|
||||||
|
|
||||||
|
QProcess::execute("sync");
|
||||||
|
Utils::wait(5);
|
||||||
|
deleteFailedData();
|
||||||
|
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 失败则删除相应数据
|
||||||
|
*/
|
||||||
|
void DataBackupProxy::deleteFailedData()
|
||||||
|
{
|
||||||
|
// 1、删除备份目录
|
||||||
|
QStringList args;
|
||||||
|
args << "-rf";
|
||||||
|
args << m_destPath;
|
||||||
|
QProcess::execute("rm", args);
|
||||||
|
|
||||||
|
// 2、删除xml文件中的备份项
|
||||||
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList parse(xmlPath);
|
||||||
|
parse.deleteItem(m_curUuid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 判断是否增量备份
|
* @brief 判断是否增量备份
|
||||||
|
@ -92,14 +135,17 @@ bool DataBackupProxy::isIncBackup()
|
||||||
/**
|
/**
|
||||||
* @brief 校验剩余空间是否满足备份
|
* @brief 校验剩余空间是否满足备份
|
||||||
*/
|
*/
|
||||||
bool DataBackupProxy::checkFreeCapacity()
|
bool DataBackupProxy::checkFreeCapacity(qint64 itotalSize)
|
||||||
{
|
{
|
||||||
qDebug() << "DataBackupProxy::checkFreeCapacity invoke begin";
|
qDebug() << "DataBackupProxy::checkFreeCapacity invoke begin";
|
||||||
|
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return false;
|
||||||
|
|
||||||
// 1、计算待备份数据的大小
|
// 1、计算待备份数据的大小
|
||||||
qint64 itotalSize = calcSizeForBackup();
|
|
||||||
m_size = itotalSize;
|
m_size = itotalSize;
|
||||||
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留5M的空间
|
||||||
itotalSize += 5 * MB;
|
itotalSize += 5 * MB;
|
||||||
|
|
||||||
// 2、计算备份分区剩余空间大小
|
// 2、计算备份分区剩余空间大小
|
||||||
|
@ -117,6 +163,12 @@ bool DataBackupProxy::checkFreeCapacity()
|
||||||
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_isOnlyCheck)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
// 开始备份
|
||||||
|
doBackup();
|
||||||
|
|
||||||
qDebug() << "DataBackupProxy::checkFreeCapacity invoke end";
|
qDebug() << "DataBackupProxy::checkFreeCapacity invoke end";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +177,7 @@ bool DataBackupProxy::checkFreeCapacity()
|
||||||
* @brief 计算备份所需空间大小
|
* @brief 计算备份所需空间大小
|
||||||
* @return 计算备份所需空间大小,单位字节
|
* @return 计算备份所需空间大小,单位字节
|
||||||
*/
|
*/
|
||||||
qint64 DataBackupProxy::calcSizeForBackup()
|
void DataBackupProxy::calcSizeForBackup()
|
||||||
{
|
{
|
||||||
QString destPath = Utils::getSysRootPath();
|
QString destPath = Utils::getSysRootPath();
|
||||||
|
|
||||||
|
@ -152,8 +204,8 @@ qint64 DataBackupProxy::calcSizeForBackup()
|
||||||
args << destPath;
|
args << destPath;
|
||||||
Utils::mkpath(destPath);
|
Utils::mkpath(destPath);
|
||||||
|
|
||||||
CalcBackupSize calcator;
|
connect(m_calc, &CalcBackupSize::finished, this, &DataBackupProxy::checkFreeCapacity);
|
||||||
return calcator.start(args);
|
m_calc->start(args, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -338,6 +390,11 @@ bool DataBackupProxy::backupData()
|
||||||
m_p = new RsyncPathToDirProcess(this);
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
connect(m_p, &RsyncPathToDirProcess::progress, this, &DataBackupProxy::progress);
|
connect(m_p, &RsyncPathToDirProcess::progress, this, &DataBackupProxy::progress);
|
||||||
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
m_isFinished = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
||||||
m_backupPoint.m_size = Utils::StringBySize(Utils::getDirOrFileSize(m_destPath));
|
m_backupPoint.m_size = Utils::StringBySize(Utils::getDirOrFileSize(m_destPath));
|
||||||
|
@ -355,6 +412,7 @@ bool DataBackupProxy::backupData()
|
||||||
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit this->workResult(result);
|
emit this->workResult(result);
|
||||||
});
|
});
|
||||||
m_p->start(args, false);
|
m_p->start(args, false);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define DATABACKUPPROXY_H
|
#define DATABACKUPPROXY_H
|
||||||
|
|
||||||
#include "workerfactory.h"
|
#include "workerfactory.h"
|
||||||
|
#include "myprocess/calcbackupsize.h"
|
||||||
#include "myprocess/rsyncpathtodirprocess.h"
|
#include "myprocess/rsyncpathtodirprocess.h"
|
||||||
#include "parsebackuplist.h"
|
#include "parsebackuplist.h"
|
||||||
|
|
||||||
|
@ -28,15 +29,20 @@ public:
|
||||||
// 任务处理
|
// 任务处理
|
||||||
virtual void doWorkEx();
|
virtual void doWorkEx();
|
||||||
|
|
||||||
|
public slots:
|
||||||
// 任务取消
|
// 任务取消
|
||||||
virtual void cancelEx();
|
virtual void cancelEx();
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
// 校验剩余空间是否满足备份
|
// 校验剩余空间是否满足备份
|
||||||
bool checkFreeCapacity();
|
bool checkFreeCapacity(qint64 itotalSize);
|
||||||
|
|
||||||
|
// 备份
|
||||||
|
void doBackup();
|
||||||
|
|
||||||
|
private:
|
||||||
// 计算备份所需空间大小
|
// 计算备份所需空间大小
|
||||||
qint64 calcSizeForBackup();
|
void calcSizeForBackup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 记录/backup/snapshots/backuplist.xml文件
|
* @brief 记录/backup/snapshots/backuplist.xml文件
|
||||||
|
@ -47,9 +53,6 @@ private:
|
||||||
// 备份准备
|
// 备份准备
|
||||||
bool doPrepare();
|
bool doPrepare();
|
||||||
|
|
||||||
// 备份
|
|
||||||
void doBackup();
|
|
||||||
|
|
||||||
// 备份系统
|
// 备份系统
|
||||||
bool backupData();
|
bool backupData();
|
||||||
|
|
||||||
|
@ -66,7 +69,16 @@ protected:
|
||||||
|
|
||||||
void do_kylin_security(const QString& dstDir);
|
void do_kylin_security(const QString& dstDir);
|
||||||
|
|
||||||
|
// 失败则删除相应数据
|
||||||
|
virtual void deleteFailedData();
|
||||||
|
|
||||||
|
// 计算备份空间大小的进程
|
||||||
|
CalcBackupSize *m_calc;
|
||||||
|
// 是否只是检测
|
||||||
|
bool m_isOnlyCheck;
|
||||||
// 是否完成
|
// 是否完成
|
||||||
|
bool m_isFinished;
|
||||||
|
// 是否成功
|
||||||
bool m_bSuccess;
|
bool m_bSuccess;
|
||||||
// 当前备份uuid
|
// 当前备份uuid
|
||||||
QString m_curUuid;
|
QString m_curUuid;
|
||||||
|
|
|
@ -16,6 +16,9 @@ GhostImageProxy::GhostImageProxy()
|
||||||
{
|
{
|
||||||
m_mksquashfs = nullptr;
|
m_mksquashfs = nullptr;
|
||||||
m_bSuccess = false;
|
m_bSuccess = false;
|
||||||
|
m_isFinished = false;
|
||||||
|
|
||||||
|
connect(this, &GhostImageProxy::cancel, this, &GhostImageProxy::cancelEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
GhostImageProxy::~GhostImageProxy()
|
GhostImageProxy::~GhostImageProxy()
|
||||||
|
@ -91,7 +94,31 @@ void GhostImageProxy::doWorkEx()
|
||||||
* @brief 任务取消
|
* @brief 任务取消
|
||||||
*/
|
*/
|
||||||
void GhostImageProxy::cancelEx()
|
void GhostImageProxy::cancelEx()
|
||||||
{}
|
{
|
||||||
|
m_bCancel = true;
|
||||||
|
if (!m_isFinished) {
|
||||||
|
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||||
|
|
||||||
|
if (m_mksquashfs)
|
||||||
|
m_mksquashfs->stop();
|
||||||
|
|
||||||
|
QProcess::execute("sync");
|
||||||
|
Utils::wait(5);
|
||||||
|
deleteFailedData();
|
||||||
|
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 失败则删除相应数据
|
||||||
|
*/
|
||||||
|
void GhostImageProxy::deleteFailedData()
|
||||||
|
{
|
||||||
|
// 1、删除镜像文件
|
||||||
|
QFile kyimg(m_kyimg);
|
||||||
|
if (kyimg.exists())
|
||||||
|
kyimg.remove();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ghost镜像
|
* @brief ghost镜像
|
||||||
|
@ -108,15 +135,20 @@ void GhostImageProxy::doGhostImage()
|
||||||
m_mksquashfs = new MkSquashFSProcess(this);
|
m_mksquashfs = new MkSquashFSProcess(this);
|
||||||
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &GhostImageProxy::progress);
|
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &GhostImageProxy::progress);
|
||||||
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
m_isFinished = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
chown(m_kyimg.toLocal8Bit().data(), m_backupWrapper.m_frontUid, m_backupWrapper.m_gid);
|
chown(m_kyimg.toLocal8Bit().data(), m_backupWrapper.m_frontUid, m_backupWrapper.m_gid);
|
||||||
QFileInfo fileInfo(m_kyimg);
|
// QFileInfo fileInfo(m_kyimg);
|
||||||
QString imgSize = Utils::StringBySize(fileInfo.size());
|
// QString imgSize = Utils::StringBySize(fileInfo.size());
|
||||||
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
// QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
Utils::writeBackupLog(time + ","
|
// Utils::writeBackupLog(time + ","
|
||||||
+ m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
// + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
+ m_backupWrapper.m_note + "," + imgSize
|
// + m_backupWrapper.m_note + "," + imgSize
|
||||||
+ ",," + m_backupWrapper.m_backupName);
|
// + ",," + m_backupWrapper.m_backupName);
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
}
|
}
|
||||||
emit this->workResult(result);
|
emit this->workResult(result);
|
||||||
|
|
|
@ -27,6 +27,8 @@ public:
|
||||||
private:
|
private:
|
||||||
void doGhostImage();
|
void doGhostImage();
|
||||||
|
|
||||||
|
void deleteFailedData();
|
||||||
|
|
||||||
// 存放.kyimg文件的目录
|
// 存放.kyimg文件的目录
|
||||||
QString m_destPath;
|
QString m_destPath;
|
||||||
// .kyimg文件
|
// .kyimg文件
|
||||||
|
@ -37,6 +39,8 @@ private:
|
||||||
|
|
||||||
// 是否成功
|
// 是否成功
|
||||||
bool m_bSuccess;
|
bool m_bSuccess;
|
||||||
|
// 是否完成
|
||||||
|
bool m_isFinished;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GHOSTIMAGEPROXY_H
|
#endif // GHOSTIMAGEPROXY_H
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QDateTime>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
#include <kysec/status.h>
|
#include <kysec/status.h>
|
||||||
|
@ -10,6 +11,7 @@
|
||||||
#include "../common/utils.h"
|
#include "../common/utils.h"
|
||||||
#include "mymountproxy.h"
|
#include "mymountproxy.h"
|
||||||
#include "workerfactory.h"
|
#include "workerfactory.h"
|
||||||
|
#include "parsebackuplist.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 构造函数
|
* @brief 构造函数
|
||||||
|
@ -131,6 +133,7 @@ int MyBackupManager::goBackup(const BackupWrapper& backupWrapper)
|
||||||
case int(BackupResult::CHECK_ENV_SUCCESS) :
|
case int(BackupResult::CHECK_ENV_SUCCESS) :
|
||||||
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
|
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
|
||||||
case int(BackupResult::BACKUP_START_SUCCESS) :
|
case int(BackupResult::BACKUP_START_SUCCESS) :
|
||||||
|
case int(BackupResult::START_CANCEL) :
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this->finished();
|
this->finished();
|
||||||
|
@ -265,6 +268,7 @@ int MyBackupManager::ghostBackup(const BackupWrapper& backupWrapper)
|
||||||
case int(BackupResult::CHECK_ENV_SUCCESS) :
|
case int(BackupResult::CHECK_ENV_SUCCESS) :
|
||||||
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
|
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
|
||||||
case int(BackupResult::GHOST_START_SUCCESS) :
|
case int(BackupResult::GHOST_START_SUCCESS) :
|
||||||
|
case int(BackupResult::START_CANCEL) :
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this->finished();
|
this->finished();
|
||||||
|
@ -299,13 +303,75 @@ int MyBackupManager::ghostBackup(const BackupWrapper& backupWrapper)
|
||||||
*/
|
*/
|
||||||
void MyBackupManager::autoBackUpForSystemUpdate_noreturn(const QString& autobackup_name, const QString& create_note, const QString& inc_note, const QString& frontUserName, int frontUid)
|
void MyBackupManager::autoBackUpForSystemUpdate_noreturn(const QString& autobackup_name, const QString& create_note, const QString& inc_note, const QString& frontUserName, int frontUid)
|
||||||
{
|
{
|
||||||
Q_UNUSED(autobackup_name)
|
qDebug("MyBackupManager::autoBackUpForSystemUpdate_noreturn invoke begin");
|
||||||
Q_UNUSED(create_note)
|
|
||||||
Q_UNUSED(inc_note)
|
|
||||||
Q_UNUSED(frontUserName)
|
|
||||||
Q_UNUSED(frontUid)
|
|
||||||
|
|
||||||
return ;
|
if (m_isActive || !lock(frontUid)) {
|
||||||
|
emit sendStartBackupResult(int(BackupResult::LOCK_PROGRAM_FAIL));
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
BackupWrapper backupWrapper;
|
||||||
|
backupWrapper.m_uuid = AUTO_BACKUP_UUID;
|
||||||
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList parseXml(xmlPath);
|
||||||
|
ParseBackupList::BackupPoint backupPoint = parseXml.findBackupPointByUuid(backupWrapper.m_uuid);
|
||||||
|
if (autobackup_name.isEmpty()) {
|
||||||
|
if (backupPoint.m_backupName.isEmpty())
|
||||||
|
backupWrapper.m_backupName = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
|
else
|
||||||
|
backupWrapper.m_backupName = backupPoint.m_backupName;
|
||||||
|
} else {
|
||||||
|
backupWrapper.m_backupName = autobackup_name;
|
||||||
|
}
|
||||||
|
backupWrapper.m_backupPaths << "/";
|
||||||
|
backupWrapper.m_backupExcludePaths = Utils::getFromExcludePathsFile();
|
||||||
|
backupWrapper.m_type = BackupType::BACKUP_SYSTEM;
|
||||||
|
backupWrapper.m_iPosition = BackupPosition::LOCAL;
|
||||||
|
backupWrapper.m_frontUserName = frontUserName;
|
||||||
|
backupWrapper.m_frontUid = frontUid;
|
||||||
|
backupWrapper.m_note = create_note.isEmpty() ? inc_note : create_note;
|
||||||
|
|
||||||
|
Worker* worker = WorkerFactory::createWorker(backupWrapper.m_type, backupWrapper.m_iPosition);
|
||||||
|
if (nullptr == worker) {
|
||||||
|
emit sendStartBackupResult(int(BackupResult::NO_FOUND_DEALCLASS));
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
worker->setParam(backupWrapper);
|
||||||
|
connect(worker, &Worker::checkResult, this, [&](int result) {
|
||||||
|
emit this->sendStartBackupResult(result);
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case int(BackupResult::CHECK_ENV_SUCCESS) :
|
||||||
|
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
|
||||||
|
case int(BackupResult::BACKUP_START_SUCCESS) :
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this->finished();
|
||||||
|
if (!Utils::isRunning("kybackup")) {
|
||||||
|
this->umountBackupPartition();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(worker, &Worker::progress, this, [&](int rate) {
|
||||||
|
emit this->sendRate(int(BackupState::WORKING), rate);
|
||||||
|
});
|
||||||
|
connect(worker, &Worker::workResult, this, [&] (bool result) {
|
||||||
|
emit this->sendBackupResult(result);
|
||||||
|
this->finished();
|
||||||
|
if (!Utils::isRunning("kybackup")) {
|
||||||
|
this->umountBackupPartition();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
worker->moveToThread(&workerThread);
|
||||||
|
connect(&workerThread, &MyThread::started, worker, &Worker::doWork);
|
||||||
|
connect(&workerThread, &MyThread::finished, worker, &Worker::deleteLater);
|
||||||
|
|
||||||
|
workerThread.start();
|
||||||
|
|
||||||
|
qDebug("MyBackupManager::autoBackUpForSystemUpdate_noreturn invoke end");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,8 +381,12 @@ void MyBackupManager::autoBackUpForSystemUpdate_noreturn(const QString& autoback
|
||||||
*/
|
*/
|
||||||
QString MyBackupManager::getBackupCommentForSystemUpdate(QString& state)
|
QString MyBackupManager::getBackupCommentForSystemUpdate(QString& state)
|
||||||
{
|
{
|
||||||
Q_UNUSED(state)
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
return "";
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList parseXml(xmlPath);
|
||||||
|
ParseBackupList::BackupPoint backupPoint = parseXml.findBackupPointByUuid(AUTO_BACKUP_UUID);
|
||||||
|
state = backupPoint.m_state;
|
||||||
|
return backupPoint.m_backupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,19 +13,27 @@ IMPLEMENT_DYNCREATE(SystemBackupProxy)
|
||||||
SystemBackupProxy::SystemBackupProxy()
|
SystemBackupProxy::SystemBackupProxy()
|
||||||
{
|
{
|
||||||
m_bSuccess = false;
|
m_bSuccess = false;
|
||||||
|
m_isFinished = false;
|
||||||
m_p = nullptr;
|
m_p = nullptr;
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
|
m_isOnlyCheck = true;
|
||||||
|
m_calc = new CalcBackupSize(this);
|
||||||
|
|
||||||
|
connect(this, &SystemBackupProxy::cancel, this, &SystemBackupProxy::cancelEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemBackupProxy::~SystemBackupProxy()
|
SystemBackupProxy::~SystemBackupProxy()
|
||||||
{
|
{
|
||||||
delete m_p;
|
delete m_p;
|
||||||
m_p = nullptr;
|
m_p = nullptr;
|
||||||
|
|
||||||
|
delete m_calc;
|
||||||
|
m_calc = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 环境检测
|
* @brief 环境检测
|
||||||
* @return false,检测失败;true,检测成功
|
* @return
|
||||||
*/
|
*/
|
||||||
bool SystemBackupProxy::checkEnvEx()
|
bool SystemBackupProxy::checkEnvEx()
|
||||||
{
|
{
|
||||||
|
@ -42,10 +50,10 @@ bool SystemBackupProxy::checkEnvEx()
|
||||||
isIncBackup();
|
isIncBackup();
|
||||||
|
|
||||||
// 3、检测空间是否满足备份
|
// 3、检测空间是否满足备份
|
||||||
bool result = checkFreeCapacity();
|
calcSizeForBackup();
|
||||||
|
|
||||||
qDebug() << "SystemBackupProxy::checkEnv invoke end";
|
qDebug() << "SystemBackupProxy::checkEnv invoke end";
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,17 +62,51 @@ bool SystemBackupProxy::checkEnvEx()
|
||||||
void SystemBackupProxy::doWorkEx()
|
void SystemBackupProxy::doWorkEx()
|
||||||
{
|
{
|
||||||
qDebug() << "SystemBackupProxy::doWorkEx invoke begin";
|
qDebug() << "SystemBackupProxy::doWorkEx invoke begin";
|
||||||
// 环境检测
|
|
||||||
if (!checkEnvEx())
|
|
||||||
return ;
|
|
||||||
|
|
||||||
// 开始备份
|
// 环境检测
|
||||||
doBackup();
|
checkEnvEx();
|
||||||
|
|
||||||
qDebug() << "SystemBackupProxy::doWorkEx invoke end";
|
qDebug() << "SystemBackupProxy::doWorkEx invoke end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 取消操作
|
||||||
|
*/
|
||||||
void SystemBackupProxy::cancelEx()
|
void SystemBackupProxy::cancelEx()
|
||||||
{}
|
{
|
||||||
|
m_bCancel = true;
|
||||||
|
if (!m_isFinished) {
|
||||||
|
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||||
|
|
||||||
|
if (m_calc)
|
||||||
|
m_calc->stop();
|
||||||
|
if (m_p)
|
||||||
|
m_p->stop();
|
||||||
|
|
||||||
|
QProcess::execute("sync");
|
||||||
|
Utils::wait(5);
|
||||||
|
deleteFailedData();
|
||||||
|
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 失败则删除相应数据
|
||||||
|
*/
|
||||||
|
void SystemBackupProxy::deleteFailedData()
|
||||||
|
{
|
||||||
|
// 1、删除备份目录
|
||||||
|
QStringList args;
|
||||||
|
args << "-rf";
|
||||||
|
args << m_destPath;
|
||||||
|
QProcess::execute("rm", args);
|
||||||
|
|
||||||
|
// 2、删除xml文件中的备份项
|
||||||
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList parse(xmlPath);
|
||||||
|
parse.deleteItem(m_curUuid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 判断是否增量备份
|
* @brief 判断是否增量备份
|
||||||
|
@ -99,12 +141,15 @@ bool SystemBackupProxy::isIncBackup()
|
||||||
/**
|
/**
|
||||||
* @brief 校验剩余空间是否满足备份
|
* @brief 校验剩余空间是否满足备份
|
||||||
*/
|
*/
|
||||||
bool SystemBackupProxy::checkFreeCapacity()
|
void SystemBackupProxy::checkFreeCapacity(qint64 itotalSize)
|
||||||
{
|
{
|
||||||
qDebug() << "SystemBackupProxy::checkFreeCapacity invoke begin";
|
qDebug() << "SystemBackupProxy::checkFreeCapacity invoke begin";
|
||||||
|
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
// 1、计算待备份数据的大小
|
// 1、计算待备份数据的大小
|
||||||
qint64 itotalSize = calcSizeForBackup();
|
|
||||||
m_size = itotalSize;
|
m_size = itotalSize;
|
||||||
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
||||||
itotalSize += 500 * MB;
|
itotalSize += 500 * MB;
|
||||||
|
@ -116,23 +161,27 @@ bool SystemBackupProxy::checkFreeCapacity()
|
||||||
qint64 freeSize = backupDisk.bytesAvailable();
|
qint64 freeSize = backupDisk.bytesAvailable();
|
||||||
|
|
||||||
// 3、校验空间是否足够
|
// 3、校验空间是否足够
|
||||||
bool result = true;
|
|
||||||
if (itotalSize > freeSize) {
|
if (itotalSize > freeSize) {
|
||||||
emit checkResult(int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH));
|
emit checkResult(int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH));
|
||||||
result = false;
|
|
||||||
} else {
|
} else {
|
||||||
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 仅仅校验,不进行备份
|
||||||
|
if (m_isOnlyCheck)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
// 4、开始备份
|
||||||
|
doBackup();
|
||||||
|
|
||||||
qDebug() << "SystemBackupProxy::checkFreeCapacity invoke end";
|
qDebug() << "SystemBackupProxy::checkFreeCapacity invoke end";
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 计算备份所需空间大小
|
* @brief 计算备份所需空间大小
|
||||||
* @return 计算备份所需空间大小,单位字节
|
* @return
|
||||||
*/
|
*/
|
||||||
qint64 SystemBackupProxy::calcSizeForBackup()
|
void SystemBackupProxy::calcSizeForBackup()
|
||||||
{
|
{
|
||||||
QString destPath = Utils::getSysRootPath();
|
QString destPath = Utils::getSysRootPath();
|
||||||
|
|
||||||
|
@ -165,8 +214,8 @@ qint64 SystemBackupProxy::calcSizeForBackup()
|
||||||
args << destPath;
|
args << destPath;
|
||||||
Utils::mkpath(destPath);
|
Utils::mkpath(destPath);
|
||||||
|
|
||||||
CalcBackupSize calcator;
|
connect(m_calc, &CalcBackupSize::finished, this, &SystemBackupProxy::checkFreeCapacity);
|
||||||
return calcator.start(args);
|
m_calc->start(args, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -304,7 +353,7 @@ bool SystemBackupProxy::doPrepare()
|
||||||
userFile.replace("//", "/");
|
userFile.replace("//", "/");
|
||||||
if (!Utils::writeFileByLines(userFile, m_backupWrapper.m_backupPaths)) {
|
if (!Utils::writeFileByLines(userFile, m_backupWrapper.m_backupPaths)) {
|
||||||
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||||
qCritical() << QString("create file %1 failed !").arg(userFile) ;
|
qCritical() << QString("create file %1 failed !").arg(userFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +361,7 @@ bool SystemBackupProxy::doPrepare()
|
||||||
excludeUserFile.replace("//", "/");
|
excludeUserFile.replace("//", "/");
|
||||||
if (!Utils::writeFileByLines(excludeUserFile, m_backupWrapper.m_backupExcludePaths)) {
|
if (!Utils::writeFileByLines(excludeUserFile, m_backupWrapper.m_backupExcludePaths)) {
|
||||||
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||||
qCritical() << QString("create file %1 failed !").arg(excludeUserFile) ;
|
qCritical() << QString("create file %1 failed !").arg(excludeUserFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,9 +472,14 @@ bool SystemBackupProxy::backupSystem()
|
||||||
m_p = new RsyncPathToDirProcess(this);
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
connect(m_p, &RsyncPathToDirProcess::progress, this, &SystemBackupProxy::progress);
|
connect(m_p, &RsyncPathToDirProcess::progress, this, &SystemBackupProxy::progress);
|
||||||
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
m_isFinished = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
||||||
// m_backupPoint.m_size = Utils::StringBySize(Utils::getDirOrFileSize(m_destPath));
|
m_backupPoint.m_size = Utils::StringBySize(Utils::getDirOrFileSize(m_destPath));
|
||||||
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
xmlPath.replace("//", "/");
|
xmlPath.replace("//", "/");
|
||||||
ParseBackupList parse(xmlPath);
|
ParseBackupList parse(xmlPath);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define SYSTEMBACKUPPROXY_H
|
#define SYSTEMBACKUPPROXY_H
|
||||||
|
|
||||||
#include "workerfactory.h"
|
#include "workerfactory.h"
|
||||||
|
#include "myprocess/calcbackupsize.h"
|
||||||
#include "myprocess/rsyncpathtodirprocess.h"
|
#include "myprocess/rsyncpathtodirprocess.h"
|
||||||
#include "parsebackuplist.h"
|
#include "parsebackuplist.h"
|
||||||
|
|
||||||
|
@ -39,10 +40,10 @@ private:
|
||||||
bool isIncBackup();
|
bool isIncBackup();
|
||||||
|
|
||||||
// 校验剩余空间是否满足备份
|
// 校验剩余空间是否满足备份
|
||||||
bool checkFreeCapacity();
|
void checkFreeCapacity(qint64 itotalSize);
|
||||||
|
|
||||||
// 计算备份所需空间大小
|
// 计算备份所需空间大小
|
||||||
qint64 calcSizeForBackup();
|
void calcSizeForBackup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 根据场景获取rsync命令参数
|
* @brief 根据场景获取rsync命令参数
|
||||||
|
@ -71,14 +72,23 @@ private:
|
||||||
|
|
||||||
void do_kylin_security(const QString& dstDir);
|
void do_kylin_security(const QString& dstDir);
|
||||||
|
|
||||||
|
// 失败则删除相应数据
|
||||||
|
void deleteFailedData();
|
||||||
|
|
||||||
|
// 是否只是检测
|
||||||
|
bool m_isOnlyCheck;
|
||||||
// 是否备份成功
|
// 是否备份成功
|
||||||
bool m_bSuccess;
|
bool m_bSuccess;
|
||||||
|
// 是否完成
|
||||||
|
bool m_isFinished;
|
||||||
// 当前备份uuid
|
// 当前备份uuid
|
||||||
QString m_curUuid;
|
QString m_curUuid;
|
||||||
// 当前备份目标目录
|
// 当前备份目标目录
|
||||||
QString m_destPath;
|
QString m_destPath;
|
||||||
// 当前备份所需空间大小
|
// 当前备份所需空间大小
|
||||||
qint64 m_size;
|
qint64 m_size;
|
||||||
|
// 计算备份空间大小的进程
|
||||||
|
CalcBackupSize *m_calc;
|
||||||
// 备份进程
|
// 备份进程
|
||||||
RsyncPathToDirProcess *m_p;
|
RsyncPathToDirProcess *m_p;
|
||||||
// 当前备份节点
|
// 当前备份节点
|
||||||
|
|
|
@ -13,20 +13,10 @@ IMPLEMENT_DYNCREATE(UDiskDataBackupProxy)
|
||||||
|
|
||||||
UDiskDataBackupProxy::UDiskDataBackupProxy()
|
UDiskDataBackupProxy::UDiskDataBackupProxy()
|
||||||
{
|
{
|
||||||
m_isFinished = false;
|
|
||||||
m_bSuccess = false;
|
|
||||||
m_p = nullptr;
|
|
||||||
m_size = 0;
|
|
||||||
m_calc = new CalcBackupSize(this);
|
|
||||||
m_isOnlyCheck = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UDiskDataBackupProxy::~UDiskDataBackupProxy()
|
UDiskDataBackupProxy::~UDiskDataBackupProxy()
|
||||||
{
|
{
|
||||||
delete m_p;
|
|
||||||
m_p = nullptr;
|
|
||||||
delete m_calc;
|
|
||||||
m_calc = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,8 +76,44 @@ void UDiskDataBackupProxy::doWorkEx()
|
||||||
qDebug() << "UDiskDataBackupProxy::doWorkEx invoke end";
|
qDebug() << "UDiskDataBackupProxy::doWorkEx invoke end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 取消操作
|
||||||
|
*/
|
||||||
void UDiskDataBackupProxy::cancelEx()
|
void UDiskDataBackupProxy::cancelEx()
|
||||||
{}
|
{
|
||||||
|
m_bCancel = true;
|
||||||
|
if (!m_isFinished) {
|
||||||
|
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||||
|
|
||||||
|
if (m_calc)
|
||||||
|
m_calc->stop();
|
||||||
|
if (m_p)
|
||||||
|
m_p->stop();
|
||||||
|
|
||||||
|
QProcess::execute("sync");
|
||||||
|
Utils::wait(5);
|
||||||
|
deleteFailedData();
|
||||||
|
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 失败则删除相应数据
|
||||||
|
*/
|
||||||
|
void UDiskDataBackupProxy::deleteFailedData()
|
||||||
|
{
|
||||||
|
// 1、删除备份目录
|
||||||
|
QStringList args;
|
||||||
|
args << "-rf";
|
||||||
|
args << m_destPath;
|
||||||
|
QProcess::execute("rm", args);
|
||||||
|
|
||||||
|
// 2、删除xml文件中的备份项
|
||||||
|
QString xmlPath = m_backupWrapper.m_prefixDestPath + BACKUP_XML_PATH;
|
||||||
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList parse(xmlPath);
|
||||||
|
parse.deleteItem(m_curUuid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 校验剩余空间是否满足备份
|
* @brief 校验剩余空间是否满足备份
|
||||||
|
@ -96,6 +122,10 @@ bool UDiskDataBackupProxy::checkFreeCapacityToUdisk(qint64 itotalSize)
|
||||||
{
|
{
|
||||||
qDebug() << "UDiskDataBackupProxy::checkFreeCapacityToUdisk invoke begin";
|
qDebug() << "UDiskDataBackupProxy::checkFreeCapacityToUdisk invoke begin";
|
||||||
|
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return false;
|
||||||
|
|
||||||
// 1、计算待备份数据的大小
|
// 1、计算待备份数据的大小
|
||||||
m_size = itotalSize;
|
m_size = itotalSize;
|
||||||
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
||||||
|
@ -296,6 +326,10 @@ bool UDiskDataBackupProxy::backupDataToUdisk()
|
||||||
m_p = new RsyncPathToDirProcess(this);
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskDataBackupProxy::progress);
|
connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskDataBackupProxy::progress);
|
||||||
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
m_isFinished = true;
|
m_isFinished = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define UDISKDATABACKUPPROXY_H
|
#define UDISKDATABACKUPPROXY_H
|
||||||
|
|
||||||
#include "databackupproxy.h"
|
#include "databackupproxy.h"
|
||||||
#include "myprocess/calcbackupsize.h"
|
|
||||||
|
|
||||||
class UDiskDataBackupProxy : public DataBackupProxy
|
class UDiskDataBackupProxy : public DataBackupProxy
|
||||||
{
|
{
|
||||||
|
@ -19,6 +18,7 @@ public:
|
||||||
// 任务处理
|
// 任务处理
|
||||||
virtual void doWorkEx();
|
virtual void doWorkEx();
|
||||||
|
|
||||||
|
public slots:
|
||||||
// 任务取消
|
// 任务取消
|
||||||
virtual void cancelEx();
|
virtual void cancelEx();
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ private slots:
|
||||||
*/
|
*/
|
||||||
bool checkDestDirExists();
|
bool checkDestDirExists();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// 失败则删除相应数据
|
||||||
|
virtual void deleteFailedData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 计算备份所需空间大小
|
// 计算备份所需空间大小
|
||||||
void calcSizeForBackupToUdisk();
|
void calcSizeForBackupToUdisk();
|
||||||
|
@ -54,13 +58,6 @@ private:
|
||||||
|
|
||||||
// 备份系统
|
// 备份系统
|
||||||
bool backupDataToUdisk();
|
bool backupDataToUdisk();
|
||||||
|
|
||||||
// 计算备份空间大小的进程
|
|
||||||
CalcBackupSize *m_calc;
|
|
||||||
// 是否只是检测
|
|
||||||
bool m_isOnlyCheck;
|
|
||||||
// 是否完成
|
|
||||||
bool m_isFinished;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UDISKDATABACKUPPROXY_H
|
#endif // UDISKDATABACKUPPROXY_H
|
||||||
|
|
|
@ -19,6 +19,8 @@ UDiskGhostImageProxy::UDiskGhostImageProxy()
|
||||||
m_p = nullptr;
|
m_p = nullptr;
|
||||||
m_bSuccess = false;
|
m_bSuccess = false;
|
||||||
m_isFinished = false;
|
m_isFinished = false;
|
||||||
|
|
||||||
|
connect(this, &UDiskGhostImageProxy::cancel, this, &UDiskGhostImageProxy::cancelEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDiskGhostImageProxy::~UDiskGhostImageProxy()
|
UDiskGhostImageProxy::~UDiskGhostImageProxy()
|
||||||
|
@ -135,7 +137,34 @@ void UDiskGhostImageProxy::doWorkEx()
|
||||||
* @brief 任务取消
|
* @brief 任务取消
|
||||||
*/
|
*/
|
||||||
void UDiskGhostImageProxy::cancelEx()
|
void UDiskGhostImageProxy::cancelEx()
|
||||||
{}
|
{
|
||||||
|
m_bCancel = true;
|
||||||
|
if (!m_isFinished) {
|
||||||
|
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||||
|
|
||||||
|
if (m_mksquashfs)
|
||||||
|
m_mksquashfs->stop();
|
||||||
|
if (m_p)
|
||||||
|
m_p->stop();
|
||||||
|
|
||||||
|
QProcess::execute("sync");
|
||||||
|
Utils::wait(5);
|
||||||
|
deleteFailedData();
|
||||||
|
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 失败则删除相应数据
|
||||||
|
*/
|
||||||
|
void UDiskGhostImageProxy::deleteFailedData()
|
||||||
|
{
|
||||||
|
// 1、删除镜像文件
|
||||||
|
QFile kyimg(m_kyimg);
|
||||||
|
if (kyimg.exists())
|
||||||
|
kyimg.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ghost镜像
|
* @brief ghost镜像
|
||||||
|
@ -152,23 +181,34 @@ void UDiskGhostImageProxy::doGhostImage()
|
||||||
m_mksquashfs = new MkSquashFSProcess(this);
|
m_mksquashfs = new MkSquashFSProcess(this);
|
||||||
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskGhostImageProxy::progress);
|
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskGhostImageProxy::progress);
|
||||||
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
chown(m_kyimg.toLocal8Bit().data(), m_backupWrapper.m_frontUid, m_backupWrapper.m_gid);
|
chown(m_kyimg.toLocal8Bit().data(), m_backupWrapper.m_frontUid, m_backupWrapper.m_gid);
|
||||||
|
|
||||||
// 同步到U盘
|
// 同步到U盘
|
||||||
m_p = new RsyncPathToDirProcess(this);
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool resultRsync) {
|
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool resultRsync) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
m_isFinished = true;
|
m_isFinished = true;
|
||||||
if (resultRsync) {
|
if (resultRsync) {
|
||||||
QFileInfo fileInfo(m_kyimg);
|
// QFileInfo fileInfo(m_kyimg);
|
||||||
QString imgSize = Utils::StringBySize(fileInfo.size());
|
// QString imgSize = Utils::StringBySize(fileInfo.size());
|
||||||
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
// QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
Utils::writeBackupLog(time + ","
|
// Utils::writeBackupLog(time + ","
|
||||||
+ m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
// + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
+ m_backupWrapper.m_note + "," + imgSize
|
// + m_backupWrapper.m_note + "," + imgSize
|
||||||
+ ",," + m_backupWrapper.m_backupName);
|
// + ",," + m_backupWrapper.m_backupName);
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
}
|
}
|
||||||
|
QFile kyimg(m_kyimg);
|
||||||
|
if (kyimg.exists())
|
||||||
|
kyimg.remove();
|
||||||
|
|
||||||
emit this->workResult(resultRsync);
|
emit this->workResult(resultRsync);
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void doGhostImage();
|
void doGhostImage();
|
||||||
bool checkDestDirExists();
|
bool checkDestDirExists();
|
||||||
|
void deleteFailedData();
|
||||||
|
|
||||||
// 存放.kyimg文件的目录
|
// 存放.kyimg文件的目录
|
||||||
QString m_destPath;
|
QString m_destPath;
|
||||||
|
|
|
@ -21,6 +21,8 @@ UDiskSystemBackupProxy::UDiskSystemBackupProxy()
|
||||||
m_calc = new CalcBackupSize(this);
|
m_calc = new CalcBackupSize(this);
|
||||||
m_isOnlyCheck = true;
|
m_isOnlyCheck = true;
|
||||||
m_mksquashfs = nullptr;
|
m_mksquashfs = nullptr;
|
||||||
|
|
||||||
|
connect(this, &UDiskSystemBackupProxy::cancel, this, &UDiskSystemBackupProxy::cancelEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDiskSystemBackupProxy::~UDiskSystemBackupProxy()
|
UDiskSystemBackupProxy::~UDiskSystemBackupProxy()
|
||||||
|
@ -41,7 +43,7 @@ UDiskSystemBackupProxy::~UDiskSystemBackupProxy()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 环境检测
|
* @brief 环境检测
|
||||||
* @return false,检测失败;true,检测成功
|
* @return
|
||||||
*/
|
*/
|
||||||
bool UDiskSystemBackupProxy::checkEnvEx()
|
bool UDiskSystemBackupProxy::checkEnvEx()
|
||||||
{
|
{
|
||||||
|
@ -93,7 +95,42 @@ void UDiskSystemBackupProxy::doWorkEx()
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDiskSystemBackupProxy::cancelEx()
|
void UDiskSystemBackupProxy::cancelEx()
|
||||||
{}
|
{
|
||||||
|
m_bCancel = true;
|
||||||
|
if (!m_isFinished) {
|
||||||
|
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||||
|
|
||||||
|
if (m_calc)
|
||||||
|
m_calc->stop();
|
||||||
|
if (m_mksquashfs)
|
||||||
|
m_mksquashfs->stop();
|
||||||
|
if (m_p)
|
||||||
|
m_p->stop();
|
||||||
|
|
||||||
|
QProcess::execute("sync");
|
||||||
|
Utils::wait(5);
|
||||||
|
deleteFailedData();
|
||||||
|
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 失败则删除相应数据
|
||||||
|
*/
|
||||||
|
void UDiskSystemBackupProxy::deleteFailedData()
|
||||||
|
{
|
||||||
|
// 1、删除备份目录
|
||||||
|
QStringList args;
|
||||||
|
args << "-rf";
|
||||||
|
args << m_destPath;
|
||||||
|
QProcess::execute("rm", args);
|
||||||
|
|
||||||
|
// 2、删除xml文件中的备份项
|
||||||
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList parse(xmlPath);
|
||||||
|
parse.deleteItem(m_curUuid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 判断是否增量备份
|
* @brief 判断是否增量备份
|
||||||
|
@ -132,6 +169,10 @@ void UDiskSystemBackupProxy::checkFreeCapacity(qint64 itotalSize)
|
||||||
{
|
{
|
||||||
qDebug() << "UDiskSystemBackupProxy::checkFreeCapacity invoke begin";
|
qDebug() << "UDiskSystemBackupProxy::checkFreeCapacity invoke begin";
|
||||||
|
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
// 1、计算待备份数据的大小
|
// 1、计算待备份数据的大小
|
||||||
m_size = itotalSize;
|
m_size = itotalSize;
|
||||||
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
||||||
|
@ -267,6 +308,10 @@ void UDiskSystemBackupProxy::doMksqushfs()
|
||||||
m_mksquashfs = new MkSquashFSProcess(this);
|
m_mksquashfs = new MkSquashFSProcess(this);
|
||||||
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskSystemBackupProxy::progress);
|
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskSystemBackupProxy::progress);
|
||||||
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [=](bool result) {
|
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [=](bool result) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
// 开始备份
|
// 开始备份
|
||||||
doBackup();
|
doBackup();
|
||||||
|
@ -456,6 +501,10 @@ bool UDiskSystemBackupProxy::backup(const QStringList &args)
|
||||||
m_p = new RsyncPathToDirProcess(this);
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskSystemBackupProxy::progress);
|
connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskSystemBackupProxy::progress);
|
||||||
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
||||||
|
// 如果是取消了操作,则不再发送其它信息
|
||||||
|
if (m_bCancel)
|
||||||
|
return ;
|
||||||
|
|
||||||
m_isFinished = true;
|
m_isFinished = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING;
|
||||||
|
|
|
@ -31,9 +31,6 @@ public:
|
||||||
// 任务处理
|
// 任务处理
|
||||||
virtual void doWorkEx();
|
virtual void doWorkEx();
|
||||||
|
|
||||||
// 任务取消
|
|
||||||
virtual void cancelEx();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -46,6 +43,9 @@ private slots:
|
||||||
// 备份
|
// 备份
|
||||||
void doBackup();
|
void doBackup();
|
||||||
|
|
||||||
|
// 任务取消
|
||||||
|
virtual void cancelEx();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 校验移动盘是否还在
|
* @brief 校验移动盘是否还在
|
||||||
* @return: bool,存在返回true;不存在返回false
|
* @return: bool,存在返回true;不存在返回false
|
||||||
|
@ -89,6 +89,9 @@ private:
|
||||||
|
|
||||||
void do_kylin_security(const QString& dstDir);
|
void do_kylin_security(const QString& dstDir);
|
||||||
|
|
||||||
|
// 失败则删除相应数据
|
||||||
|
void deleteFailedData();
|
||||||
|
|
||||||
// 计算备份空间大小的进程
|
// 计算备份空间大小的进程
|
||||||
CalcBackupSize *m_calc;
|
CalcBackupSize *m_calc;
|
||||||
// 压缩进程
|
// 压缩进程
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
Worker::Worker() :
|
Worker::Worker() :
|
||||||
QObject(nullptr)
|
QObject(nullptr),
|
||||||
|
m_bCancel(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Worker::~Worker()
|
Worker::~Worker()
|
||||||
|
@ -25,14 +26,6 @@ void Worker::doWork()
|
||||||
doWorkEx();
|
doWorkEx();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 任务取消
|
|
||||||
*/
|
|
||||||
void Worker::cancel()
|
|
||||||
{
|
|
||||||
cancelEx();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 环境检测,个性化部分派生类去实现
|
// 环境检测,个性化部分派生类去实现
|
||||||
bool Worker::checkEnvEx()
|
bool Worker::checkEnvEx()
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,8 @@ signals:
|
||||||
void progress(int currentRate);
|
void progress(int currentRate);
|
||||||
// 工作结果信号
|
// 工作结果信号
|
||||||
void workResult(bool result);
|
void workResult(bool result);
|
||||||
|
// 任务取消
|
||||||
|
void cancel();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// 环境检测
|
// 环境检测
|
||||||
|
@ -30,9 +32,6 @@ public slots:
|
||||||
// 任务处理
|
// 任务处理
|
||||||
void doWork();
|
void doWork();
|
||||||
|
|
||||||
// 任务取消
|
|
||||||
void cancel();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 环境检测,个性化部分派生类去实现
|
// 环境检测,个性化部分派生类去实现
|
||||||
virtual bool checkEnvEx();
|
virtual bool checkEnvEx();
|
||||||
|
@ -49,6 +48,8 @@ public:
|
||||||
public:
|
public:
|
||||||
// 同一时间只能运行一个备份/还原等操作
|
// 同一时间只能运行一个备份/还原等操作
|
||||||
BackupWrapper m_backupWrapper;
|
BackupWrapper m_backupWrapper;
|
||||||
|
// 是否取消操作
|
||||||
|
bool m_bCancel;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -267,6 +267,10 @@ enum class BackupResult {
|
||||||
MKSQUASHFS_START_SUCCESS,
|
MKSQUASHFS_START_SUCCESS,
|
||||||
// mksquashfs压缩img文件失败
|
// mksquashfs压缩img文件失败
|
||||||
MKSQUASHFS_DO_FAIL,
|
MKSQUASHFS_DO_FAIL,
|
||||||
|
// 开始取消操作
|
||||||
|
START_CANCEL,
|
||||||
|
// 取消操作成功
|
||||||
|
CANCEL_SUCCESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MYDEFINE_H
|
#endif // MYDEFINE_H
|
||||||
|
|
|
@ -34,15 +34,18 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
|
||||||
|
|
||||||
QStringList headerLabels;
|
QStringList headerLabels;
|
||||||
// 注意:此处的列需要和枚举Column_Index一一对应
|
// 注意:此处的列需要和枚举Column_Index一一对应
|
||||||
headerLabels << tr("Backup Name") << tr("UUID") << tr("Backup Time") << tr("Backup Size") << tr("Backup Device") << QObject::tr("Backup State") << QObject::tr("PrefixPath");
|
headerLabels << tr("Backup Name") << tr("UUID") << tr("Backup Time") << tr("Backup Size") << tr("Position") << QObject::tr("Backup State") << QObject::tr("PrefixPath");
|
||||||
m_tableWidget = new QTableWidget;
|
m_tableWidget = new QTableWidget;
|
||||||
m_tableWidget->setColumnCount(headerLabels.size());
|
m_tableWidget->setColumnCount(headerLabels.size());
|
||||||
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
|
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
|
||||||
m_tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
m_tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
// m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
// m_tableWidget->horizontalHeader()->setSectionResizeMode(Column_Index::Backup_Name, QHeaderView::Stretch);
|
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Name, 300);
|
||||||
// m_tableWidget->horizontalHeader()->setSectionResizeMode(Column_Index::UUID, QHeaderView::Stretch);
|
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::UUID, 320);
|
||||||
// m_tableWidget->horizontalHeader()->setSectionResizeMode(Column_Index::Backup_Device, QHeaderView::Stretch);
|
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Time, 150);
|
||||||
|
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Size, 120);
|
||||||
|
m_tableWidget->horizontalHeader()->setSectionResizeMode(Column_Index::Backup_Device, QHeaderView::Stretch);
|
||||||
|
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_State, 150);
|
||||||
m_tableWidget->horizontalHeader()->setTextElideMode( Qt::ElideRight);
|
m_tableWidget->horizontalHeader()->setTextElideMode( Qt::ElideRight);
|
||||||
m_tableWidget->horizontalHeader()->setFixedHeight(30);
|
m_tableWidget->horizontalHeader()->setFixedHeight(30);
|
||||||
m_tableWidget->verticalHeader()->setHidden(true); // 好像隐藏不掉
|
m_tableWidget->verticalHeader()->setHidden(true); // 好像隐藏不掉
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
UUID,
|
UUID,
|
||||||
Backup_Time,
|
Backup_Time,
|
||||||
Backup_Size,
|
Backup_Size,
|
||||||
Backup_Device,
|
Backup_Device, // 即备份位置Position
|
||||||
Backup_State,
|
Backup_State,
|
||||||
Prefix_Path
|
Prefix_Path
|
||||||
};
|
};
|
||||||
|
|
|
@ -1235,8 +1235,6 @@ void DataBackup::initFifthWidget()
|
||||||
labelTip->setIsOriginal(true);
|
labelTip->setIsOriginal(true);
|
||||||
labelTip->setFontWordWrap(true);
|
labelTip->setFontWordWrap(true);
|
||||||
labelTip->setMinimumWidth(700);
|
labelTip->setMinimumWidth(700);
|
||||||
// 不要使用电脑,以防数据丢失
|
|
||||||
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
|
||||||
hlayoutCenterFont2->addStretch();
|
hlayoutCenterFont2->addStretch();
|
||||||
hlayoutCenterFont2->addWidget(labelTip);
|
hlayoutCenterFont2->addWidget(labelTip);
|
||||||
hlayoutCenterFont2->addStretch();
|
hlayoutCenterFont2->addStretch();
|
||||||
|
@ -1247,7 +1245,6 @@ void DataBackup::initFifthWidget()
|
||||||
MyPushButton *cancel = new MyPushButton(fifth);
|
MyPushButton *cancel = new MyPushButton(fifth);
|
||||||
cancel->setFixedSize(97, 36);
|
cancel->setFixedSize(97, 36);
|
||||||
cancel->setText(tr("cancel"));
|
cancel->setText(tr("cancel"));
|
||||||
cancel->setEnabled(true);
|
|
||||||
cancel->setAutoRepeat(true);
|
cancel->setAutoRepeat(true);
|
||||||
hlayoutCenterFont3->addStretch();
|
hlayoutCenterFont3->addStretch();
|
||||||
hlayoutCenterFont3->addWidget(cancel);
|
hlayoutCenterFont3->addWidget(cancel);
|
||||||
|
@ -1277,6 +1274,9 @@ void DataBackup::initFifthWidget()
|
||||||
connect(this, &DataBackup::startBackup, this, [=] {
|
connect(this, &DataBackup::startBackup, this, [=] {
|
||||||
progressBar->setPersent(0);
|
progressBar->setPersent(0);
|
||||||
movie->start();
|
movie->start();
|
||||||
|
// 不要使用电脑,以防数据丢失
|
||||||
|
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
||||||
|
cancel->setEnabled(true);
|
||||||
|
|
||||||
// 开始备份
|
// 开始备份
|
||||||
this->on_backup_start();
|
this->on_backup_start();
|
||||||
|
@ -1291,7 +1291,13 @@ void DataBackup::initFifthWidget()
|
||||||
// 取消备份
|
// 取消备份
|
||||||
connect(cancel, &MyPushButton::clicked, this, [=](bool checked) {
|
connect(cancel, &MyPushButton::clicked, this, [=](bool checked) {
|
||||||
Q_UNUSED(checked)
|
Q_UNUSED(checked)
|
||||||
// TODO
|
// 确定取消当前操作?
|
||||||
|
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"), QObject::tr("Are you sure to cancel the operation?"), QObject::tr("Ok"), QObject::tr("Cancel"))) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
cancel->setEnabled(false);
|
||||||
|
if (m_pInterface)
|
||||||
|
m_pInterface->cancel();
|
||||||
});
|
});
|
||||||
|
|
||||||
addWidget(fifth);
|
addWidget(fifth);
|
||||||
|
@ -1359,7 +1365,7 @@ void DataBackup::on_checkBackup_end(int result)
|
||||||
break;
|
break;
|
||||||
case int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH):
|
case int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH):
|
||||||
// 备份空间不足
|
// 备份空间不足
|
||||||
errMsg = tr("The storage for backup is not enough.");
|
errMsg = tr("The storage for backup is not enough");
|
||||||
// 建议释放空间后重试
|
// 建议释放空间后重试
|
||||||
errTip = tr("Retry after release space");
|
errTip = tr("Retry after release space");
|
||||||
break;
|
break;
|
||||||
|
@ -1373,10 +1379,16 @@ void DataBackup::on_checkBackup_end(int result)
|
||||||
case int(BackupResult::WRITE_STORAGEINFO_ADD_ITEM_FAIL):
|
case int(BackupResult::WRITE_STORAGEINFO_ADD_ITEM_FAIL):
|
||||||
case int(BackupResult::WRITE_STORAGEINFO_UPDATE_ITEM_FAIL):
|
case int(BackupResult::WRITE_STORAGEINFO_UPDATE_ITEM_FAIL):
|
||||||
// 创建备份点目录失败
|
// 创建备份点目录失败
|
||||||
errMsg = tr("Failed to create the backup point directory.");
|
errMsg = tr("Failed to create the backup point directory");
|
||||||
// 请检查备份目录是否有写权限
|
// 请检查备份目录是否有写权限
|
||||||
errTip = tr("Please check backup partition permissions");
|
errTip = tr("Please check backup partition permissions");
|
||||||
break;
|
break;
|
||||||
|
case int(BackupResult::CANCEL_SUCCESS):
|
||||||
|
// 已经取消本次备份
|
||||||
|
errMsg = tr("The backup had been canceled");
|
||||||
|
// 如需要可重新发起备份
|
||||||
|
errTip = tr("Re-initiate the backup if necessary");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
bRst = true;
|
bRst = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1566,7 +1578,7 @@ void DataBackup::initLastWidget()
|
||||||
QIcon icon = QIcon::fromTheme("dialog-error.png", QIcon(":/symbos/dialog-error.png"));
|
QIcon icon = QIcon::fromTheme("dialog-error.png", QIcon(":/symbos/dialog-error.png"));
|
||||||
resultLogo->setPixmap(icon.pixmap(QSize(20,20)));
|
resultLogo->setPixmap(icon.pixmap(QSize(20,20)));
|
||||||
resultLogo->setVisible(true);
|
resultLogo->setVisible(true);
|
||||||
// 环境校验失败
|
// 备份失败
|
||||||
bigTitle->setDeplayText(tr("The backup is failed"));
|
bigTitle->setDeplayText(tr("The backup is failed"));
|
||||||
dot1->setVisible(true);
|
dot1->setVisible(true);
|
||||||
dot2->setVisible(true);
|
dot2->setVisible(true);
|
||||||
|
|
|
@ -170,8 +170,8 @@ void DataRestore::on_button_beginRestore_clicked(bool checked)
|
||||||
selectRestoreDialog->deleteLater();
|
selectRestoreDialog->deleteLater();
|
||||||
return ;
|
return ;
|
||||||
} else if (checkIsNeedReboot()){
|
} else if (checkIsNeedReboot()){
|
||||||
// 包含用户家目录,还原完成后将自动重启
|
// 包含用户家目录,还原完成后需要重启
|
||||||
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"), QObject::tr("Contains the user's home directory, which will automatically reboot after restoration"), QObject::tr("Continue"), QObject::tr("Cancel"))) {
|
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"), QObject::tr("Contains the user's home directory, which need to reboot after restoration"), QObject::tr("Continue"), QObject::tr("Cancel"))) {
|
||||||
selectRestoreDialog->deleteLater();
|
selectRestoreDialog->deleteLater();
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,8 +690,6 @@ void GhostImage::initForthWidget()
|
||||||
labelTip->setIsOriginal(true);
|
labelTip->setIsOriginal(true);
|
||||||
labelTip->setFontWordWrap(true);
|
labelTip->setFontWordWrap(true);
|
||||||
labelTip->setMinimumWidth(700);
|
labelTip->setMinimumWidth(700);
|
||||||
// 不要使用电脑,以防数据丢失
|
|
||||||
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
|
||||||
hlayoutCenterFont2->addStretch();
|
hlayoutCenterFont2->addStretch();
|
||||||
hlayoutCenterFont2->addWidget(labelTip);
|
hlayoutCenterFont2->addWidget(labelTip);
|
||||||
hlayoutCenterFont2->addStretch();
|
hlayoutCenterFont2->addStretch();
|
||||||
|
@ -749,8 +747,11 @@ void GhostImage::initForthWidget()
|
||||||
connect(this, &GhostImage::startGhost, this, [=] {
|
connect(this, &GhostImage::startGhost, this, [=] {
|
||||||
progressBar->setPersent(0);
|
progressBar->setPersent(0);
|
||||||
movie->start();
|
movie->start();
|
||||||
|
// 不要使用电脑,以防数据丢失
|
||||||
|
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
||||||
labelTip_1->setVisible(false);
|
labelTip_1->setVisible(false);
|
||||||
labelTip_1->setDeplayText("");
|
labelTip_1->setDeplayText("");
|
||||||
|
cancel->setEnabled(true);
|
||||||
|
|
||||||
// 开始备份
|
// 开始备份
|
||||||
this->on_ghost_start();
|
this->on_ghost_start();
|
||||||
|
@ -765,7 +766,13 @@ void GhostImage::initForthWidget()
|
||||||
// 取消备份
|
// 取消备份
|
||||||
connect(cancel, &MyPushButton::clicked, this, [=](bool checked) {
|
connect(cancel, &MyPushButton::clicked, this, [=](bool checked) {
|
||||||
Q_UNUSED(checked)
|
Q_UNUSED(checked)
|
||||||
// TODO
|
// 确定取消当前操作?
|
||||||
|
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"), QObject::tr("Are you sure to cancel the operation?"), QObject::tr("Ok"), QObject::tr("Cancel"))) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
cancel->setEnabled(false);
|
||||||
|
if (m_pInterface)
|
||||||
|
m_pInterface->cancel();
|
||||||
});
|
});
|
||||||
|
|
||||||
addWidget(forth);
|
addWidget(forth);
|
||||||
|
@ -867,6 +874,12 @@ void GhostImage::on_checkGhost_end(int result)
|
||||||
// 请检查刚刚是否有删除备份点操作
|
// 请检查刚刚是否有删除备份点操作
|
||||||
errTip = tr("Check whether the backup point has been deleted");
|
errTip = tr("Check whether the backup point has been deleted");
|
||||||
break;
|
break;
|
||||||
|
case int(BackupResult::CANCEL_SUCCESS):
|
||||||
|
// 已经取消本次镜像制作
|
||||||
|
errMsg = tr("The image creation had been canceled");
|
||||||
|
// 如需要可重新发起镜像制作
|
||||||
|
errTip = tr("Re-initiate the image creation if necessary");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
bRst = true;
|
bRst = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -20,7 +20,7 @@ ManageBackupPointList::ManageBackupPointList(QWidget *parent, BackupPointType ba
|
||||||
}
|
}
|
||||||
|
|
||||||
// 隐藏备份点大小Backup Size字段
|
// 隐藏备份点大小Backup Size字段
|
||||||
m_tableWidget->hideColumn(Column_Index::Backup_Size);
|
// m_tableWidget->hideColumn(Column_Index::Backup_Size);
|
||||||
initTableWidget();
|
initTableWidget();
|
||||||
|
|
||||||
// 您可以删除不需要的备份,更多细节请参考“操作日志”
|
// 您可以删除不需要的备份,更多细节请参考“操作日志”
|
||||||
|
|
|
@ -53,7 +53,10 @@ void OperationLog::initFirstWidget()
|
||||||
m_tableWidget->setColumnCount(headerLabels.size());
|
m_tableWidget->setColumnCount(headerLabels.size());
|
||||||
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
|
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
|
||||||
m_tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
m_tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
// m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
|
m_tableWidget->horizontalHeader()->resizeSection(0, 340);
|
||||||
|
m_tableWidget->horizontalHeader()->resizeSection(2, 150);
|
||||||
|
m_tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||||
m_tableWidget->horizontalHeader()->setTextElideMode(Qt::ElideRight);
|
m_tableWidget->horizontalHeader()->setTextElideMode(Qt::ElideRight);
|
||||||
m_tableWidget->horizontalHeader()->setFixedHeight(30);
|
m_tableWidget->horizontalHeader()->setFixedHeight(30);
|
||||||
m_tableWidget->verticalHeader()->setHidden(true); // 好像隐藏不掉
|
m_tableWidget->verticalHeader()->setHidden(true); // 好像隐藏不掉
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "../../common/utils.h"
|
#include "../../common/utils.h"
|
||||||
#include "../globalbackupinfo.h"
|
#include "../globalbackupinfo.h"
|
||||||
#include "managebackuppointlist.h"
|
#include "managebackuppointlist.h"
|
||||||
|
#include "messageboxutils.h"
|
||||||
|
|
||||||
SystemBackup::SystemBackup(QWidget *parent /*= nullptr*/) :
|
SystemBackup::SystemBackup(QWidget *parent /*= nullptr*/) :
|
||||||
QStackedWidget(parent),
|
QStackedWidget(parent),
|
||||||
|
@ -822,8 +823,6 @@ void SystemBackup::initFifthWidget()
|
||||||
labelTip->setIsOriginal(true);
|
labelTip->setIsOriginal(true);
|
||||||
labelTip->setFontWordWrap(true);
|
labelTip->setFontWordWrap(true);
|
||||||
labelTip->setMinimumWidth(700);
|
labelTip->setMinimumWidth(700);
|
||||||
// 不要使用电脑,以防数据丢失
|
|
||||||
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
|
||||||
hlayoutCenterFont2->addStretch();
|
hlayoutCenterFont2->addStretch();
|
||||||
hlayoutCenterFont2->addWidget(labelTip);
|
hlayoutCenterFont2->addWidget(labelTip);
|
||||||
hlayoutCenterFont2->addStretch();
|
hlayoutCenterFont2->addStretch();
|
||||||
|
@ -846,7 +845,6 @@ void SystemBackup::initFifthWidget()
|
||||||
MyPushButton *cancel = new MyPushButton(fifth);
|
MyPushButton *cancel = new MyPushButton(fifth);
|
||||||
cancel->setFixedSize(97, 36);
|
cancel->setFixedSize(97, 36);
|
||||||
cancel->setText(tr("cancel"));
|
cancel->setText(tr("cancel"));
|
||||||
cancel->setEnabled(true);
|
|
||||||
cancel->setAutoRepeat(true);
|
cancel->setAutoRepeat(true);
|
||||||
hlayoutCenterFont3->addStretch();
|
hlayoutCenterFont3->addStretch();
|
||||||
hlayoutCenterFont3->addWidget(cancel);
|
hlayoutCenterFont3->addWidget(cancel);
|
||||||
|
@ -878,8 +876,11 @@ void SystemBackup::initFifthWidget()
|
||||||
connect(this, &SystemBackup::startBackup, this, [=] {
|
connect(this, &SystemBackup::startBackup, this, [=] {
|
||||||
progressBar->setPersent(0);
|
progressBar->setPersent(0);
|
||||||
movie->start();
|
movie->start();
|
||||||
|
// 不要使用电脑,以防数据丢失
|
||||||
|
labelTip->setDeplayText(tr("Do not use computers in case of data loss"));
|
||||||
labelTip_1->setVisible(false);
|
labelTip_1->setVisible(false);
|
||||||
labelTip_1->setDeplayText("");
|
labelTip_1->setDeplayText("");
|
||||||
|
cancel->setEnabled(true);
|
||||||
|
|
||||||
// 开始备份
|
// 开始备份
|
||||||
this->on_backup_start();
|
this->on_backup_start();
|
||||||
|
@ -894,7 +895,13 @@ void SystemBackup::initFifthWidget()
|
||||||
// 取消备份
|
// 取消备份
|
||||||
connect(cancel, &MyPushButton::clicked, this, [=](bool checked) {
|
connect(cancel, &MyPushButton::clicked, this, [=](bool checked) {
|
||||||
Q_UNUSED(checked)
|
Q_UNUSED(checked)
|
||||||
// TODO
|
// 确定取消当前操作?
|
||||||
|
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"), QObject::tr("Are you sure to cancel the operation?"), QObject::tr("Ok"), QObject::tr("Cancel"))) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
cancel->setEnabled(false);
|
||||||
|
if (m_pInterface)
|
||||||
|
m_pInterface->cancel();
|
||||||
});
|
});
|
||||||
|
|
||||||
addWidget(fifth);
|
addWidget(fifth);
|
||||||
|
@ -965,7 +972,7 @@ void SystemBackup::on_checkBackup_end(int result)
|
||||||
break;
|
break;
|
||||||
case int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH):
|
case int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH):
|
||||||
// 备份空间不足
|
// 备份空间不足
|
||||||
errMsg = tr("The storage for backup is not enough.");
|
errMsg = tr("The storage for backup is not enough");
|
||||||
// 建议释放空间后重试
|
// 建议释放空间后重试
|
||||||
errTip = tr("Retry after release space");
|
errTip = tr("Retry after release space");
|
||||||
break;
|
break;
|
||||||
|
@ -979,20 +986,26 @@ void SystemBackup::on_checkBackup_end(int result)
|
||||||
case int(BackupResult::WRITE_STORAGEINFO_ADD_ITEM_FAIL):
|
case int(BackupResult::WRITE_STORAGEINFO_ADD_ITEM_FAIL):
|
||||||
case int(BackupResult::WRITE_STORAGEINFO_UPDATE_ITEM_FAIL):
|
case int(BackupResult::WRITE_STORAGEINFO_UPDATE_ITEM_FAIL):
|
||||||
// 创建备份点目录失败
|
// 创建备份点目录失败
|
||||||
errMsg = tr("Failed to create the backup point directory.");
|
errMsg = tr("Failed to create the backup point directory");
|
||||||
// 请检查备份目录是否有写权限
|
// 请检查备份目录是否有写权限
|
||||||
errTip = tr("Please check backup partition permissions");
|
errTip = tr("Please check backup partition permissions");
|
||||||
break;
|
break;
|
||||||
case int(BackupResult::MKSQUASHFS_START_SUCCESS):
|
case int(BackupResult::MKSQUASHFS_START_SUCCESS):
|
||||||
// 正压缩系统到本地磁盘,请耐心等待。。。
|
// 正压缩系统到本地磁盘,请耐心等待...
|
||||||
errTip = tr("The system is being compressed to the local disk, please wait patiently...");
|
errTip = tr("The system is being compressed to the local disk, please wait patiently...");
|
||||||
emit this->backupWarnning(errTip);
|
emit this->backupWarnning(errTip);
|
||||||
return;
|
return;
|
||||||
case int(BackupResult::BACKUP_START_SUCCESS):
|
case int(BackupResult::BACKUP_START_SUCCESS):
|
||||||
// 正在传输备份文件到移动设备,即将完成。。。
|
// 正在传输备份文件到移动设备,即将完成...
|
||||||
errTip = tr("Transferring backup files to mobile device, about to be completed...");
|
errTip = tr("Transferring backup files to mobile device, about to be completed...");
|
||||||
emit this->backupWarnning(errTip);
|
emit this->backupWarnning(errTip);
|
||||||
return;
|
return;
|
||||||
|
case int(BackupResult::CANCEL_SUCCESS):
|
||||||
|
// 已经取消本次备份
|
||||||
|
errMsg = tr("The backup had been canceled");
|
||||||
|
// 如需要可重新发起备份
|
||||||
|
errTip = tr("Re-initiate the backup if necessary");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
bRst = true;
|
bRst = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1182,7 +1195,7 @@ void SystemBackup::initLastWidget()
|
||||||
QIcon icon = QIcon::fromTheme("dialog-error.png", QIcon(":/symbos/dialog-error.png"));
|
QIcon icon = QIcon::fromTheme("dialog-error.png", QIcon(":/symbos/dialog-error.png"));
|
||||||
resultLogo->setPixmap(icon.pixmap(QSize(20,20)));
|
resultLogo->setPixmap(icon.pixmap(QSize(20,20)));
|
||||||
resultLogo->setVisible(true);
|
resultLogo->setVisible(true);
|
||||||
// 环境校验失败
|
// 备份失败
|
||||||
bigTitle->setDeplayText(tr("The backup is failed"));
|
bigTitle->setDeplayText(tr("The backup is failed"));
|
||||||
dot1->setVisible(true);
|
dot1->setVisible(true);
|
||||||
dot2->setVisible(true);
|
dot2->setVisible(true);
|
||||||
|
|
Loading…
Reference in New Issue