From 5db97cf5f4c500da4caf6994ee9da65de0af3700 Mon Sep 17 00:00:00 2001 From: zhaominyong Date: Wed, 9 Mar 2022 16:54:25 +0800 Subject: [PATCH] =?UTF-8?q?109348=20=E3=80=90=E5=A4=87=E4=BB=BD=E8=BF=98?= =?UTF-8?q?=E5=8E=9F4.0.14=E3=80=91=E9=80=89=E6=8B=A9=E5=9C=A8=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E8=AE=BE=E5=A4=87=E4=B8=8A=E5=A4=87=E4=BB=BD=E7=9A=84?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=BF=9B=E8=A1=8C=E7=B3=BB=E7=BB=9F=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=E6=97=B6=EF=BC=8C=E5=9C=A8=E5=88=B0=E8=BF=98=E5=8E=9F?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=AD=A5=E9=AA=A4=E6=97=B6=EF=BC=8C=E6=8B=94?= =?UTF-8?q?=E5=87=BA=E7=A7=BB=E5=8A=A8=E8=AE=BE=E5=A4=87=EF=BC=8C=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E5=8D=A1=E5=9C=A8100%=E4=B8=8D=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup-daemon/udiskdatarestoreproxy.cpp | 15 +++++++++++++-- backup-daemon/udiskdatarestoreproxy.h | 3 ++- backup-daemon/udisksystemrestoreproxy.cpp | 16 +++++++++++++--- backup-daemon/udisksystemrestoreproxy.h | 2 ++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/backup-daemon/udiskdatarestoreproxy.cpp b/backup-daemon/udiskdatarestoreproxy.cpp index df00450..4447af7 100755 --- a/backup-daemon/udiskdatarestoreproxy.cpp +++ b/backup-daemon/udiskdatarestoreproxy.cpp @@ -18,6 +18,7 @@ UDiskDataRestoreProxy::UDiskDataRestoreProxy() m_bSuccess = false; m_isFinished = false; m_p = nullptr; + m_isForce = false; } /** @@ -136,6 +137,7 @@ void UDiskDataRestoreProxy::restoreData() m_p = new RsyncPathToDirProcess(this); connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskDataRestoreProxy::progress); connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) { + m_isForce = false; m_bSuccess = result; m_isFinished = true; if (result) { @@ -158,10 +160,19 @@ void UDiskDataRestoreProxy::restoreData() bool UDiskDataRestoreProxy::checkUdiskExists() { if (!m_isFinished) { - if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) + // 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了) + if (m_isForce) { + emit this->workResult(false); + } + + if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) { m_p->stop(); - else + // 10s钟后如果还没有退出,则强制退出 + QTimer::singleShot(10*1000, this, &UDiskDataRestoreProxy::checkUdiskExists); + m_isForce = true; + } else { QTimer::singleShot(1*1000, this, &UDiskDataRestoreProxy::checkUdiskExists); + } } return true; diff --git a/backup-daemon/udiskdatarestoreproxy.h b/backup-daemon/udiskdatarestoreproxy.h index bca65e9..c939fff 100755 --- a/backup-daemon/udiskdatarestoreproxy.h +++ b/backup-daemon/udiskdatarestoreproxy.h @@ -56,7 +56,8 @@ private: RsyncPathToDirProcess *m_p; // 当前备份节点 ParseBackupList::BackupPoint m_backupPoint; - + // 强制结束标志(stop后没反应的情况,系统处于睡眠状态) + bool m_isForce; }; #endif // UDISKDATARESTOREPROXY_H diff --git a/backup-daemon/udisksystemrestoreproxy.cpp b/backup-daemon/udisksystemrestoreproxy.cpp index 61a5428..a2040bd 100755 --- a/backup-daemon/udisksystemrestoreproxy.cpp +++ b/backup-daemon/udisksystemrestoreproxy.cpp @@ -18,6 +18,7 @@ UDiskSystemRestoreProxy::UDiskSystemRestoreProxy() { m_isFinished = false; m_p = nullptr; + m_isForce = false; } /** @@ -378,6 +379,7 @@ void UDiskSystemRestoreProxy::restoreSystem() m_p = new RsyncPathToDirProcess(this); connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskSystemRestoreProxy::progress); connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) { + m_isForce = false; 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)); @@ -451,7 +453,6 @@ void UDiskSystemRestoreProxy::updateGrubUUid() } } - /** * @brief 监控移动设备是否还在 * @return true-在;false-不在 @@ -459,10 +460,19 @@ void UDiskSystemRestoreProxy::updateGrubUUid() bool UDiskSystemRestoreProxy::checkUdiskExists() { if (!m_isFinished) { - if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) + // 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了) + if (m_isForce) { + emit this->workResult(false); + } + + if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) { m_p->stop(); - else + // 10s钟后如果还没有退出,则强制退出 + QTimer::singleShot(10*1000, this, &UDiskSystemRestoreProxy::checkUdiskExists); + m_isForce = true; + } else { QTimer::singleShot(1*1000, this, &UDiskSystemRestoreProxy::checkUdiskExists); + } } return true; diff --git a/backup-daemon/udisksystemrestoreproxy.h b/backup-daemon/udisksystemrestoreproxy.h index db83295..3b7f058 100755 --- a/backup-daemon/udisksystemrestoreproxy.h +++ b/backup-daemon/udisksystemrestoreproxy.h @@ -72,6 +72,8 @@ private: RsyncPathToDirProcess *m_p; // 当前备份节点 ParseBackupList::BackupPoint m_backupPoint; + // 强制结束标志(stop后没反应的情况,系统处于睡眠状态) + bool m_isForce; }; #endif // UDISKSYSTEMRESTOREPROXY_H