From 76137966f5061e2bc4186471d1c119662cc492d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=B0=91=E5=8B=87?= Date: Sat, 17 Sep 2022 09:57:21 +0800 Subject: [PATCH] =?UTF-8?q?140066=20=E3=80=90=E5=A4=87=E4=BB=BD=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=E3=80=91=E8=BF=98=E5=8E=9F=E7=B3=BB=E7=BB=9F=E5=90=8E?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=88=9B=E5=BB=BA=E5=90=8C=E5=90=8D=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup-daemon/mybackupmanager.cpp | 7 ++++++ .../myprocess/rsyncpathtodirprocess.cpp | 1 + backup-daemon/systemrestoreproxy.cpp | 22 ++++++++++++++----- backup-daemon/workerfactory.h | 6 +++++ common/utils.cpp | 2 +- kybackup/module/systemrestore.cpp | 3 +++ 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/backup-daemon/mybackupmanager.cpp b/backup-daemon/mybackupmanager.cpp index a2d521c..9b956bb 100755 --- a/backup-daemon/mybackupmanager.cpp +++ b/backup-daemon/mybackupmanager.cpp @@ -199,6 +199,13 @@ int MyBackupManager::goRestore(const BackupWrapper& backupWrapper) connect(worker, &Worker::progress, this, [&](int rate) { emit this->progress(int(BackupState::WORKING), rate); }); + connect(worker, &Worker::otherSignal, this, [&](int type) { + // 结束ukui-session-tools的锁定,以便后面的用户登出操作 + if (Worker::OtherSignal::UKUI_SESSION_LOCK_END == type) { + this->uninhibit(); + emit this->sendRestoreResult(true); + } + }); connect(worker, &Worker::workResult, this, [&] (bool result) { emit this->sendRestoreResult(result); this->finished(); diff --git a/backup-daemon/myprocess/rsyncpathtodirprocess.cpp b/backup-daemon/myprocess/rsyncpathtodirprocess.cpp index 9866df4..4266a1d 100755 --- a/backup-daemon/myprocess/rsyncpathtodirprocess.cpp +++ b/backup-daemon/myprocess/rsyncpathtodirprocess.cpp @@ -96,6 +96,7 @@ void RsyncPathToDirProcess::rsync_finished(int exitCode, QProcess::ExitStatus) emit finished(true); } else { qDebug() << "RsyncPathToDirProcess::rsync_finished unblock mode"; + emit progress(100); m_syncProcess->start("sync"); if (!m_syncProcess->waitForStarted()) { qDebug() << "sync start failed"; diff --git a/backup-daemon/systemrestoreproxy.cpp b/backup-daemon/systemrestoreproxy.cpp index 3909858..7df8df6 100755 --- a/backup-daemon/systemrestoreproxy.cpp +++ b/backup-daemon/systemrestoreproxy.cpp @@ -119,6 +119,7 @@ bool SystemRestoreProxy::restoreEfi() if (!Utils::isDirEmpty(efiPath)) { // 1、修复源数据 repairEfi(); + sync(); // 2、重新rw读写挂载 remountEfi(); @@ -371,18 +372,27 @@ void SystemRestoreProxy::restoreSystem() break; } if (FACTORY_BACKUP_UUID == m_curUuid && m_backupWrapper.m_type == BackupType::RESTORE_SYSTEM) { + emit this->otherSignal(UKUI_SESSION_LOCK_END); + Utils::wait(5); + // 出厂还原有的机器上删除/home/xxx有残留,故在此再强制删除一下,sudo rm -rf命令一遍还删除不了(报错:无法删除/home/xx/.config:目录非空,应该是删除后又自动生成了),多删除几次还不是非常干净,^_^ removeHome(QString(Utils::getSysRootPath() + "/home").replace("//", "/")); removeHome(QString(Utils::getSysRootPath() + "/data/home").replace("//", "/")); - } - QProcess::execute("sync"); - Utils::wait(5); - emit this->workResult(result); - Utils::wait(2); + QProcess::execute("sync"); + Utils::wait(2); + emit this->workResult(result); + } else { + QProcess::execute("sync"); + Utils::wait(5); + emit this->workResult(result); + Utils::wait(3); + } + reboot(RB_AUTOBOOT); + } else { + emit this->workResult(result); } - emit this->workResult(result); }); m_p->start(args, false); diff --git a/backup-daemon/workerfactory.h b/backup-daemon/workerfactory.h index b827721..f24bb53 100755 --- a/backup-daemon/workerfactory.h +++ b/backup-daemon/workerfactory.h @@ -11,6 +11,10 @@ class Worker : public QObject { Q_OBJECT +public: + enum OtherSignal{ + UKUI_SESSION_LOCK_END, + }; public: explicit Worker(); virtual ~Worker(); @@ -24,6 +28,8 @@ signals: void workResult(bool result); // 任务取消 void cancel(); + // 其它信号 + void otherSignal(int type); public slots: // 环境检测 diff --git a/common/utils.cpp b/common/utils.cpp index 2bce0c9..813aa69 100755 --- a/common/utils.cpp +++ b/common/utils.cpp @@ -478,7 +478,7 @@ bool Utils::generateExcludePathsFile() // 系统安装后有的会将/data/home /data/root挂载到的/home /root上,实际文件是存放在/data/home /data/root下面,为了统一标准保留/home /root排除/data/home /data/root QStringList excludes; Utils::excludeFstabBindPath(excludes); - // Utils::excludeSomeHomePath(excludes); + Utils::excludeSomeHomePath(excludes); Utils::excludeCustomizePath(excludes); for (const QString& item : excludes) { in << item << END_LINE; diff --git a/kybackup/module/systemrestore.cpp b/kybackup/module/systemrestore.cpp index 4c2dd84..b4bd1e4 100755 --- a/kybackup/module/systemrestore.cpp +++ b/kybackup/module/systemrestore.cpp @@ -963,6 +963,9 @@ void SystemRestore::initLastWidget() labelError2->setVisible(false); retry->setVisible(false); homePage->setVisible(false); + + Utils::wait(2); + QProcess::execute("ukui-session-tools --logout"); } else { resultLogo->setThemeIconSchema("dialog-error", ":/symbos/dialog-error"); resultLogo->setVisible(true);