From 8dbd01c6d5ada1940e8aec4ce92faa6440f6bdb3 Mon Sep 17 00:00:00 2001 From: zhaominyong Date: Wed, 9 Mar 2022 17:19:49 +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/udiskdatabackupproxy.cpp | 28 ++++++++++++-------- backup-daemon/udiskdatabackupproxy.h | 3 +++ backup-daemon/udiskdatarestoreproxy.cpp | 1 + backup-daemon/udiskghostImageproxy.cpp | 30 ++++++++++++--------- backup-daemon/udiskghostImageproxy.h | 2 ++ backup-daemon/udisksystembackupproxy.cpp | 32 ++++++++++++----------- backup-daemon/udisksystembackupproxy.h | 2 ++ backup-daemon/udisksystemrestoreproxy.cpp | 1 + 8 files changed, 60 insertions(+), 39 deletions(-) diff --git a/backup-daemon/udiskdatabackupproxy.cpp b/backup-daemon/udiskdatabackupproxy.cpp index 15f7c11..f7e8c38 100755 --- a/backup-daemon/udiskdatabackupproxy.cpp +++ b/backup-daemon/udiskdatabackupproxy.cpp @@ -17,6 +17,7 @@ UDiskDataBackupProxy::UDiskDataBackupProxy() UDiskDataBackupProxy::~UDiskDataBackupProxy() { + m_isForce = false; } /** @@ -337,6 +338,7 @@ bool UDiskDataBackupProxy::backupDataToUdisk() if (m_bCancel) return ; + m_isForce = false; m_isFinished = true; if (result) { m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING; @@ -378,19 +380,23 @@ bool UDiskDataBackupProxy::backupDataToUdisk() */ bool UDiskDataBackupProxy::checkDestDirExists() { - QDir dir(m_backupWrapper.m_prefixDestPath); - if (!dir.exists()) { - qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath); - - if (m_p) - m_p->stop(); - - return false; - } - if (!m_isFinished) { - QTimer::singleShot(1*1000, this, &UDiskDataBackupProxy::checkDestDirExists); + // 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了) + if (m_isForce) { + emit this->workResult(false); + return false; + } + + if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath) && m_p != nullptr) { + qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath); + m_p->stop(); + // 10s钟后如果还没有退出,则强制退出 + QTimer::singleShot(10*1000, this, &UDiskDataBackupProxy::checkDestDirExists); + m_isForce = true; + } else { + QTimer::singleShot(1*1000, this, &UDiskDataBackupProxy::checkDestDirExists); + } } return true; diff --git a/backup-daemon/udiskdatabackupproxy.h b/backup-daemon/udiskdatabackupproxy.h index df9a8af..6721d55 100755 --- a/backup-daemon/udiskdatabackupproxy.h +++ b/backup-daemon/udiskdatabackupproxy.h @@ -58,6 +58,9 @@ private: // 备份系统 bool backupDataToUdisk(); + + // 强制结束标志(stop后没反应的情况,系统处于睡眠状态) + bool m_isForce; }; #endif // UDISKDATABACKUPPROXY_H diff --git a/backup-daemon/udiskdatarestoreproxy.cpp b/backup-daemon/udiskdatarestoreproxy.cpp index 4447af7..fab64c4 100755 --- a/backup-daemon/udiskdatarestoreproxy.cpp +++ b/backup-daemon/udiskdatarestoreproxy.cpp @@ -163,6 +163,7 @@ bool UDiskDataRestoreProxy::checkUdiskExists() // 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了) if (m_isForce) { emit this->workResult(false); + return false; } if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) { diff --git a/backup-daemon/udiskghostImageproxy.cpp b/backup-daemon/udiskghostImageproxy.cpp index 2886697..8e73273 100755 --- a/backup-daemon/udiskghostImageproxy.cpp +++ b/backup-daemon/udiskghostImageproxy.cpp @@ -19,6 +19,7 @@ UDiskGhostImageProxy::UDiskGhostImageProxy() m_p = nullptr; m_bSuccess = false; m_isFinished = false; + m_isForce = false; connect(this, &UDiskGhostImageProxy::cancel, this, &UDiskGhostImageProxy::cancelEx); } @@ -203,6 +204,7 @@ void UDiskGhostImageProxy::doGhostImage() if (m_bCancel) return ; + m_isForce = false; m_isFinished = true; if (resultRsync) { // QFileInfo fileInfo(m_kyimg); @@ -252,21 +254,23 @@ void UDiskGhostImageProxy::doGhostImage() */ bool UDiskGhostImageProxy::checkDestDirExists() { - QDir dir(m_backupWrapper.m_prefixDestPath); - if (!dir.exists()) { - qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath); - - if (m_mksquashfs) - m_mksquashfs->stop(); - if (m_p) - m_p->stop(); - - return false; - } - if (!m_isFinished) { - QTimer::singleShot(1*1000, this, &UDiskGhostImageProxy::checkDestDirExists); + // 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了) + if (m_isForce) { + emit this->workResult(false); + return false; + } + + if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath) && m_p != nullptr) { + qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath); + m_p->stop(); + // 10s钟后如果还没有退出,则强制退出 + QTimer::singleShot(10*1000, this, &UDiskGhostImageProxy::checkDestDirExists); + m_isForce = true; + } else { + QTimer::singleShot(1*1000, this, &UDiskGhostImageProxy::checkDestDirExists); + } } return true; diff --git a/backup-daemon/udiskghostImageproxy.h b/backup-daemon/udiskghostImageproxy.h index 761d457..e2252cd 100755 --- a/backup-daemon/udiskghostImageproxy.h +++ b/backup-daemon/udiskghostImageproxy.h @@ -43,6 +43,8 @@ private: bool m_bSuccess; // 是否结束 bool m_isFinished; + // 强制结束标志(stop后没反应的情况,系统处于睡眠状态) + bool m_isForce; }; diff --git a/backup-daemon/udisksystembackupproxy.cpp b/backup-daemon/udisksystembackupproxy.cpp index 63f78fa..bf45e95 100755 --- a/backup-daemon/udisksystembackupproxy.cpp +++ b/backup-daemon/udisksystembackupproxy.cpp @@ -21,6 +21,7 @@ UDiskSystemBackupProxy::UDiskSystemBackupProxy() m_calc = new CalcBackupSize(this); m_isOnlyCheck = true; m_mksquashfs = nullptr; + m_isForce = false; connect(this, &UDiskSystemBackupProxy::cancel, this, &UDiskSystemBackupProxy::cancelEx); } @@ -511,6 +512,7 @@ bool UDiskSystemBackupProxy::backup(const QStringList &args) if (m_bCancel) return ; + m_isForce = false; m_isFinished = true; if (result) { m_backupPoint.m_state = BACKUP_PARSE_STATE_SUCCESS_STRTING; @@ -565,23 +567,23 @@ void UDiskSystemBackupProxy::do_kylin_security(const QString& dstDir) */ bool UDiskSystemBackupProxy::checkDestDirExists() { - QDir dir(m_backupWrapper.m_prefixDestPath); - if (!dir.exists()) { - qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath); - - if (m_calc) - m_calc->stop(); - if (m_mksquashfs) - m_mksquashfs->stop(); - if (m_p) - m_p->stop(); - - return false; - } - if (!m_isFinished) { - QTimer::singleShot(1*1000, this, &UDiskSystemBackupProxy::checkDestDirExists); + // 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了) + if (m_isForce) { + emit this->workResult(false); + return false; + } + + if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath) && m_p != nullptr) { + qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath); + m_p->stop(); + // 10s钟后如果还没有退出,则强制退出 + QTimer::singleShot(10*1000, this, &UDiskSystemBackupProxy::checkDestDirExists); + m_isForce = true; + } else { + QTimer::singleShot(1*1000, this, &UDiskSystemBackupProxy::checkDestDirExists); + } } return true; diff --git a/backup-daemon/udisksystembackupproxy.h b/backup-daemon/udisksystembackupproxy.h index ead5126..0677fd1 100755 --- a/backup-daemon/udisksystembackupproxy.h +++ b/backup-daemon/udisksystembackupproxy.h @@ -115,6 +115,8 @@ private: bool m_isOnlyCheck; // img文件存放路径 QString m_imgPath; + // 强制结束标志(stop后没反应的情况,系统处于睡眠状态) + bool m_isForce; }; #endif // UDISKSYSTEMBACKUPPROXY_H diff --git a/backup-daemon/udisksystemrestoreproxy.cpp b/backup-daemon/udisksystemrestoreproxy.cpp index a2040bd..d041ba9 100755 --- a/backup-daemon/udisksystemrestoreproxy.cpp +++ b/backup-daemon/udisksystemrestoreproxy.cpp @@ -463,6 +463,7 @@ bool UDiskSystemRestoreProxy::checkUdiskExists() // 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了) if (m_isForce) { emit this->workResult(false); + return false; } if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) {