bug修复

This commit is contained in:
zhaominyong 2021-11-17 11:47:15 +08:00
parent 26a86d60ea
commit e25679a409
8 changed files with 52 additions and 34 deletions

View File

@ -132,7 +132,7 @@ int MyBackupManager::goBackup(const BackupWrapper& backupWrapper)
emit this->progress(int(BackupState::WORKING), rate); emit this->progress(int(BackupState::WORKING), rate);
}); });
connect(worker, &Worker::workResult, this, [&] (bool result) { connect(worker, &Worker::workResult, this, [&] (bool result) {
emit this->sendBackupResult(result); emit this->backupFinished(result);
this->finished(); this->finished();
}); });
worker->moveToThread(&workerThread); worker->moveToThread(&workerThread);

View File

@ -180,27 +180,27 @@ QStringList SystemBackupProxy::getRsyncArgs(SystemBackupScene scene)
switch (scene) { switch (scene) {
case SystemBackupScene::SYSTEM_BACKUP : case SystemBackupScene::SYSTEM_BACKUP :
args << "-avAHXW"; args << "-avAHXr";
args << "--progress"; args << "--info=progress2";
args << "--no-inc-recursive"; args << "--no-inc-recursive";
args << "--ignore-missing-args"; args << "--ignore-missing-args";
break ; break ;
case SystemBackupScene::INC_SYSTEM_BACKUP : case SystemBackupScene::INC_SYSTEM_BACKUP :
args << "-avAXr"; args << "-avAXr";
args << "--progress"; args << "--info=progress2";
args << "--no-inc-recursive"; args << "--no-inc-recursive";
args << "--ignore-missing-args"; args << "--ignore-missing-args";
args << QString("--link-dest=../../%1/data").arg(m_backupWrapper.m_baseUuid); args << QString("--link-dest=../../%1/data").arg(m_backupWrapper.m_baseUuid);
break ; break ;
case SystemBackupScene::INC_SYSTEM_BACKUP_AT_BASE : case SystemBackupScene::INC_SYSTEM_BACKUP_AT_BASE :
args << "-avAHXr"; args << "-avAHXr";
args << "--progress"; args << "--info=progress2";
args << "--no-inc-recursive"; args << "--no-inc-recursive";
args << "--ignore-missing-args"; args << "--ignore-missing-args";
args << "--delete"; args << "--delete";
break ; break ;
case SystemBackupScene::TRY_SYSTEM_BACKUP : case SystemBackupScene::TRY_SYSTEM_BACKUP :
args << "-aAHXWn"; args << "-aAHXrn";
args << "--stats"; args << "--stats";
args << "--ignore-missing-args"; args << "--ignore-missing-args";
break ; break ;
@ -218,7 +218,7 @@ QStringList SystemBackupProxy::getRsyncArgs(SystemBackupScene scene)
break ; break ;
case SystemBackupScene::EFI_BACKUP : case SystemBackupScene::EFI_BACKUP :
args << "-avAHXr"; args << "-avAHXr";
args << "--progress"; args << "--info=progress2";
args << "--ignore-missing-args"; args << "--ignore-missing-args";
break ; break ;
default: default:

View File

@ -168,13 +168,13 @@ QStringList UDiskSystemBackupProxy::getRsyncArgs(UDiskSystemBackupScene scene)
switch (scene) { switch (scene) {
case UDiskSystemBackupScene::SYSTEM_BACKUP : case UDiskSystemBackupScene::SYSTEM_BACKUP :
args << "-avAHXW"; args << "-avAHXr";
args << "--progress"; args << "--info=progress2";
args << "--no-inc-recursive"; args << "--no-inc-recursive";
args << "--ignore-missing-args"; args << "--ignore-missing-args";
break ; break ;
case UDiskSystemBackupScene::TRY_SYSTEM_BACKUP : case UDiskSystemBackupScene::TRY_SYSTEM_BACKUP :
args << "-aAHXWn"; args << "-aAHXrn";
args << "--stats"; args << "--stats";
args << "--ignore-missing-args"; args << "--ignore-missing-args";
break ; break ;
@ -182,6 +182,11 @@ QStringList UDiskSystemBackupProxy::getRsyncArgs(UDiskSystemBackupScene scene)
return args; return args;
} }
// --exclude=排除路径设置
for (const QString & item : m_backupWrapper.m_backupExcludePaths) {
args << QString("--exclude=%1").arg(item);
}
return args; return args;
} }

View File

@ -5,8 +5,8 @@
QDBusArgument &operator<<(QDBusArgument &argument, const BackupWrapper &backupWrapper) QDBusArgument &operator<<(QDBusArgument &argument, const BackupWrapper &backupWrapper)
{ {
argument.beginStructure(); argument.beginStructure();
argument << backupWrapper.m_type << backupWrapper.m_comment << backupWrapper.m_backupName argument << backupWrapper.m_type << backupWrapper.m_iPosition << backupWrapper.m_comment << backupWrapper.m_backupName
<< backupWrapper.m_uuid << backupWrapper.m_backupPaths << backupWrapper.m_backupExcludePaths << backupWrapper.m_uuid << backupWrapper.m_backupPaths << backupWrapper.m_backupExcludePaths << backupWrapper.m_prefixDestPath
<< backupWrapper.m_note << backupWrapper.m_frontUserName << backupWrapper.m_frontUid << backupWrapper.m_note << backupWrapper.m_frontUserName << backupWrapper.m_frontUid
<< backupWrapper.m_gid; << backupWrapper.m_gid;
argument.endStructure(); argument.endStructure();
@ -17,8 +17,8 @@ QDBusArgument &operator<<(QDBusArgument &argument, const BackupWrapper &backupWr
const QDBusArgument &operator>>(const QDBusArgument &argument, BackupWrapper &backupWrapper) const QDBusArgument &operator>>(const QDBusArgument &argument, BackupWrapper &backupWrapper)
{ {
argument.beginStructure(); argument.beginStructure();
argument >> backupWrapper.m_type >> backupWrapper.m_comment >> backupWrapper.m_backupName argument >> backupWrapper.m_type >> backupWrapper.m_iPosition >> backupWrapper.m_comment >> backupWrapper.m_backupName
>> backupWrapper.m_uuid >> backupWrapper.m_backupPaths >> backupWrapper.m_backupExcludePaths >> backupWrapper.m_uuid >> backupWrapper.m_backupPaths >> backupWrapper.m_backupExcludePaths >> backupWrapper.m_prefixDestPath
>> backupWrapper.m_note >> backupWrapper.m_frontUserName >> backupWrapper.m_frontUid >> backupWrapper.m_note >> backupWrapper.m_frontUserName >> backupWrapper.m_frontUid
>> backupWrapper.m_gid; >> backupWrapper.m_gid;
argument.endStructure(); argument.endStructure();

View File

@ -80,9 +80,9 @@ enum BackupType {
*/ */
struct BackupWrapper { struct BackupWrapper {
// 操作类型,如:系统备份, 系统还原 // 操作类型,如:系统备份, 系统还原
int m_type = 0; int m_type = -1;
// 本地备份还是U盘备份: 0-本地备份1-移动设备备份 // 本地备份还是U盘备份: 0-本地备份1-移动设备备份
int m_iPosition = 0; int m_iPosition = -1;
// 备份名称,用于识别备份的,默认是时间 // 备份名称,用于识别备份的,默认是时间
QString m_comment; QString m_comment;
// 备份名称用来替换m_comment // 备份名称用来替换m_comment
@ -103,6 +103,8 @@ struct BackupWrapper {
int m_frontUid = -1; int m_frontUid = -1;
// 备份用户所属组id // 备份用户所属组id
int m_gid = -1; int m_gid = -1;
// follow are not input parameters
// 是否增量备份 // 是否增量备份
bool m_bIncrement = false; bool m_bIncrement = false;
// 新增备份点时增量备份的基准uuid // 新增备份点时增量备份的基准uuid

View File

@ -56,7 +56,7 @@ public Q_SLOTS: // METHODS
return asyncCallWithArgumentList(QStringLiteral("autoBackUpForSystemUpdate_noreturn"), argumentList); return asyncCallWithArgumentList(QStringLiteral("autoBackUpForSystemUpdate_noreturn"), argumentList);
} }
inline QDBusPendingReply<int> checkEnv(BackupWrapper backupWrapper) inline QDBusPendingReply<int> checkEnv(const BackupWrapper& backupWrapper)
{ {
QList<QVariant> argumentList; QList<QVariant> argumentList;
argumentList << QVariant::fromValue(backupWrapper); argumentList << QVariant::fromValue(backupWrapper);

View File

@ -319,9 +319,8 @@ void SystemBackup::initThirdWidget()
recheck->setEnabled(true); recheck->setEnabled(true);
recheck->setAutoRepeat(true); recheck->setAutoRepeat(true);
connect(recheck, &MyPushButton::clicked, this, [=](bool checked) { connect(recheck, &MyPushButton::clicked, this, [=](bool checked) {
// 为测试下一步骤,这里暂时先改为下一步 Q_UNUSED(checked)
// emit this->startCheckEnv(); emit this->startCheckEnv();
this->on_next_clicked(checked);
}); });
// 开始检测 // 开始检测
@ -432,6 +431,7 @@ void SystemBackup::on_checkEnv_start()
backupPath.replace("//", "/"); backupPath.replace("//", "/");
backupWrapper.m_backupPaths << backupPath; backupWrapper.m_backupPaths << backupPath;
backupWrapper.m_prefixDestPath = m_prefixDestPath; backupWrapper.m_prefixDestPath = m_prefixDestPath;
backupWrapper.m_backupExcludePaths.append(Utils::getFromExcludePathsFile());
backupWrapper.m_frontUid = getuid(); backupWrapper.m_frontUid = getuid();
backupWrapper.m_gid = getgid(); backupWrapper.m_gid = getgid();
m_pInterface->checkEnv(backupWrapper); m_pInterface->checkEnv(backupWrapper);
@ -485,7 +485,8 @@ void SystemBackup::on_checkEnv_end(int result)
emit checkEnvResult(bRst, errMsg, errTip); emit checkEnvResult(bRst, errMsg, errTip);
GlobelBackupInfo::inst().setIsBusy(false); GlobelBackupInfo::inst().setIsBusy(false);
disconnect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkEnv_end); disconnect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkEnv_end);
m_pInterface->deleteLater(); delete m_pInterface;
m_pInterface = nullptr;
} }
/** /**
@ -723,6 +724,7 @@ void SystemBackup::initFifthWidget()
void SystemBackup::on_backup_start() void SystemBackup::on_backup_start()
{ {
GlobelBackupInfo::inst().setIsBusy(true); GlobelBackupInfo::inst().setIsBusy(true);
m_systemBackupState = SystemBackupState::BACKUPING;
m_pInterface = new ComKylinBackupManagerInterface("com.kylin.backup", "/", QDBusConnection::systemBus(), this); m_pInterface = new ComKylinBackupManagerInterface("com.kylin.backup", "/", QDBusConnection::systemBus(), this);
connect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkBackup_end); connect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkBackup_end);
connect(m_pInterface, &ComKylinBackupManagerInterface::progress, this, &SystemBackup::progress); connect(m_pInterface, &ComKylinBackupManagerInterface::progress, this, &SystemBackup::progress);
@ -744,6 +746,7 @@ void SystemBackup::on_backup_start()
backupPath.replace("//", "/"); backupPath.replace("//", "/");
backupWrapper.m_backupPaths << backupPath; backupWrapper.m_backupPaths << backupPath;
backupWrapper.m_prefixDestPath = m_prefixDestPath; backupWrapper.m_prefixDestPath = m_prefixDestPath;
backupWrapper.m_backupExcludePaths.append(Utils::getFromExcludePathsFile());
backupWrapper.m_frontUid = getuid(); backupWrapper.m_frontUid = getuid();
backupWrapper.m_gid = getgid(); backupWrapper.m_gid = getgid();
m_pInterface->goBackup(backupWrapper); m_pInterface->goBackup(backupWrapper);
@ -755,7 +758,6 @@ void SystemBackup::on_backup_start()
*/ */
void SystemBackup::on_checkBackup_end(int result) void SystemBackup::on_checkBackup_end(int result)
{ {
m_systemBackupState = SystemBackupState::IDEL;
bool bRst = false; bool bRst = false;
QString errMsg, errTip; QString errMsg, errTip;
switch (result) { switch (result) {
@ -802,13 +804,17 @@ void SystemBackup::on_checkBackup_end(int result)
break; break;
} }
this->on_next_clicked(true); if (!bRst) {
emit checkEnvResult(bRst, errMsg, errTip); GlobelBackupInfo::inst().setIsBusy(false);
GlobelBackupInfo::inst().setIsBusy(false); m_systemBackupState = SystemBackupState::IDEL;
disconnect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkEnv_end); this->on_next_clicked(true);
disconnect(m_pInterface, &ComKylinBackupManagerInterface::progress, this, &SystemBackup::progress); emit checkBackupResult(bRst, errMsg, errTip);
disconnect(m_pInterface, &ComKylinBackupManagerInterface::backupFinished, this, &SystemBackup::on_backup_end); disconnect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkEnv_end);
m_pInterface->deleteLater(); disconnect(m_pInterface, &ComKylinBackupManagerInterface::progress, this, &SystemBackup::progress);
disconnect(m_pInterface, &ComKylinBackupManagerInterface::backupFinished, this, &SystemBackup::on_backup_end);
delete m_pInterface;
m_pInterface = nullptr;
}
} }
/** /**
@ -821,19 +827,21 @@ void SystemBackup::on_backup_end(bool result)
this->on_next_clicked(true); this->on_next_clicked(true);
if (result) { if (result) {
emit checkEnvResult(result); emit checkBackupResult(result);
} else { } else {
// 备份过程中出现错误 // 备份过程中出现错误
QString errMsg = tr("An error occurred during backup"); QString errMsg = tr("An error occurred during backup");
// 错误信息参考日志文件:/var/log/backup.log // 错误信息参考日志文件:/var/log/backup.log
QString errTip = tr("Error messages refer to log file : /var/log/backup.log"); QString errTip = tr("Error messages refer to log file : /var/log/backup.log");
emit checkEnvResult(result, errMsg, errTip); emit checkBackupResult(result, errMsg, errTip);
} }
GlobelBackupInfo::inst().setIsBusy(false); GlobelBackupInfo::inst().setIsBusy(false);
disconnect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkEnv_end); disconnect(m_pInterface, &ComKylinBackupManagerInterface::sendEnvCheckResult, this, &SystemBackup::on_checkEnv_end);
disconnect(m_pInterface, &ComKylinBackupManagerInterface::progress, this, &SystemBackup::progress);
disconnect(m_pInterface, &ComKylinBackupManagerInterface::backupFinished, this, &SystemBackup::on_backup_end); disconnect(m_pInterface, &ComKylinBackupManagerInterface::backupFinished, this, &SystemBackup::on_backup_end);
m_pInterface->deleteLater(); delete m_pInterface;
m_pInterface = nullptr;
} }
/** /**
@ -902,13 +910,13 @@ void SystemBackup::initLastWidget()
// --------------成功界面-------------- // --------------成功界面--------------
// 返回首页 // 返回首页
MyPushButton *homePage = new MyPushButton(last); MyPushButton *homePage = new MyPushButton(last);
homePage->setGeometry(310, 330, 97, 36); homePage->setGeometry(310, 240, 97, 36);
homePage->setText(tr("home page")); homePage->setText(tr("home page"));
homePage->setEnabled(true); homePage->setEnabled(true);
homePage->setAutoRepeat(true); homePage->setAutoRepeat(true);
// 备份检测结果 // 备份检测结果
connect(this, &SystemBackup::checkEnvResult, this, [=](bool result, const QString &errMsg, const QString &errTip) { connect(this, &SystemBackup::checkBackupResult, this, [=](bool result, const QString &errMsg, const QString &errTip) {
if (result) { if (result) {
QIcon icon = QIcon::fromTheme("ukui-dialog-success", QIcon(":/symbos/ukui-dialog-success.png")); QIcon icon = QIcon::fromTheme("ukui-dialog-success", QIcon(":/symbos/ukui-dialog-success.png"));
resultLogo->setPixmap(icon.pixmap(QSize(20,20))); resultLogo->setPixmap(icon.pixmap(QSize(20,20)));
@ -929,6 +937,8 @@ void SystemBackup::initLastWidget()
resultLogo->setVisible(true); resultLogo->setVisible(true);
// 环境校验失败 // 环境校验失败
bigTitle->setDeplayText(tr("The backup is failed")); bigTitle->setDeplayText(tr("The backup is failed"));
dot1->setVisible(true);
dot2->setVisible(true);
labelError1->setDeplayText(errMsg); labelError1->setDeplayText(errMsg);
labelError2->setDeplayText(errTip); labelError2->setDeplayText(errTip);
retry->setVisible(true); retry->setVisible(true);

View File

@ -44,6 +44,7 @@ private:
signals: signals:
void startCheckEnv(); void startCheckEnv();
void checkEnvResult(bool result, const QString &errMsg = "", const QString &errTip = ""); void checkEnvResult(bool result, const QString &errMsg = "", const QString &errTip = "");
void checkBackupResult(bool result, const QString &errMsg = "", const QString &errTip = "");
void startBackup(); void startBackup();
void progress(int state, int rate); void progress(int state, int rate);