U盘备份还原期间,强拔U盘逻辑优化
This commit is contained in:
parent
ef407bbdf1
commit
c271efac59
|
@ -13,6 +13,7 @@ IMPLEMENT_DYNCREATE(UDiskDataBackupProxy)
|
|||
|
||||
UDiskDataBackupProxy::UDiskDataBackupProxy()
|
||||
{
|
||||
m_isForce = false;
|
||||
}
|
||||
|
||||
UDiskDataBackupProxy::~UDiskDataBackupProxy()
|
||||
|
@ -132,6 +133,12 @@ bool UDiskDataBackupProxy::checkFreeCapacityToUdisk(qint64 itotalSize)
|
|||
if (m_bCancel)
|
||||
return false;
|
||||
|
||||
// 拔掉U盘的场景
|
||||
if (m_isForce) {
|
||||
emit this->checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1、计算待备份数据的大小
|
||||
m_size = itotalSize;
|
||||
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
||||
|
@ -388,12 +395,15 @@ bool UDiskDataBackupProxy::checkDestDirExists()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath) && m_p != nullptr) {
|
||||
if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath)) {
|
||||
qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath);
|
||||
m_isForce = true;
|
||||
if (m_calc != nullptr)
|
||||
m_calc->stop();
|
||||
if (m_p != nullptr)
|
||||
m_p->stop();
|
||||
// 10s钟后如果还没有退出,则强制退出
|
||||
QTimer::singleShot(10*1000, this, &UDiskDataBackupProxy::checkDestDirExists);
|
||||
m_isForce = true;
|
||||
} else {
|
||||
QTimer::singleShot(1*1000, this, &UDiskDataBackupProxy::checkDestDirExists);
|
||||
}
|
||||
|
|
|
@ -166,7 +166,8 @@ bool UDiskDataRestoreProxy::checkUdiskExists()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) {
|
||||
if (Utils::isDirEmpty(m_backupPath)) {
|
||||
if (m_p != nullptr)
|
||||
m_p->stop();
|
||||
// 10s钟后如果还没有退出,则强制退出
|
||||
QTimer::singleShot(10*1000, this, &UDiskDataRestoreProxy::checkUdiskExists);
|
||||
|
|
|
@ -193,7 +193,7 @@ void UDiskGhostImageProxy::doGhostImage()
|
|||
if (m_bCancel)
|
||||
return ;
|
||||
|
||||
if (result) {
|
||||
if (result && !m_isForce) {
|
||||
chown(m_kyimg.toLocal8Bit().data(), m_backupWrapper.m_frontUid, m_backupWrapper.m_gid);
|
||||
|
||||
// 同步到U盘
|
||||
|
@ -262,8 +262,11 @@ bool UDiskGhostImageProxy::checkDestDirExists()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath) && m_p != nullptr) {
|
||||
if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath)) {
|
||||
qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath);
|
||||
if (m_mksquashfs)
|
||||
m_mksquashfs->stop();
|
||||
if (m_p)
|
||||
m_p->stop();
|
||||
// 10s钟后如果还没有退出,则强制退出
|
||||
QTimer::singleShot(10*1000, this, &UDiskGhostImageProxy::checkDestDirExists);
|
||||
|
|
|
@ -179,6 +179,12 @@ void UDiskSystemBackupProxy::checkFreeCapacity(qint64 itotalSize)
|
|||
if (m_bCancel)
|
||||
return ;
|
||||
|
||||
// 拔掉U盘的场景
|
||||
if (m_isForce) {
|
||||
emit this->checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1、计算待备份数据的大小
|
||||
m_size = itotalSize;
|
||||
// 备份过程中会有一些临时文件产生,会占用一部分空间,故我们预留500M的空间
|
||||
|
@ -318,7 +324,7 @@ void UDiskSystemBackupProxy::doMksqushfs()
|
|||
if (m_bCancel)
|
||||
return ;
|
||||
|
||||
if (result) {
|
||||
if (result && !m_isForce) {
|
||||
// 开始备份
|
||||
doBackup();
|
||||
} else {
|
||||
|
@ -575,12 +581,17 @@ bool UDiskSystemBackupProxy::checkDestDirExists()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath) && m_p != nullptr) {
|
||||
if (Utils::isDirEmpty(m_backupWrapper.m_prefixDestPath)) {
|
||||
qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath);
|
||||
m_isForce = true;
|
||||
if (m_calc != nullptr)
|
||||
m_calc->stop();
|
||||
if (m_mksquashfs != nullptr)
|
||||
m_mksquashfs->stop();
|
||||
if (m_p != nullptr)
|
||||
m_p->stop();
|
||||
// 10s钟后如果还没有退出,则强制退出
|
||||
QTimer::singleShot(10*1000, this, &UDiskSystemBackupProxy::checkDestDirExists);
|
||||
m_isForce = true;
|
||||
} else {
|
||||
QTimer::singleShot(1*1000, this, &UDiskSystemBackupProxy::checkDestDirExists);
|
||||
}
|
||||
|
|
|
@ -358,6 +358,13 @@ bool UDiskSystemRestoreProxy::doPrepare()
|
|||
*/
|
||||
void UDiskSystemRestoreProxy::restoreSystem()
|
||||
{
|
||||
// 理论上开始不会走下面这个U盘拔出的校验
|
||||
if (m_isForce) {
|
||||
qCritical("U盘已拔出");
|
||||
emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 停止安全防护, 迁移到业务开始的锁定中去
|
||||
// QProcess::execute("systemctl stop kysec-init.service");
|
||||
|
||||
|
@ -462,15 +469,18 @@ bool UDiskSystemRestoreProxy::checkUdiskExists()
|
|||
if (!m_isFinished) {
|
||||
// 拔掉U盘后,没有响应的场景(怀疑可能是某应用程序关闭引起,希望不是dbus服务关掉了)
|
||||
if (m_isForce) {
|
||||
qCritical() << QString("强制退出");
|
||||
emit this->workResult(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Utils::isDirEmpty(m_backupPath) && m_p != nullptr) {
|
||||
if (Utils::isDirEmpty(m_backupPath)) {
|
||||
qCritical() << QString("srcDir %s is not exist!").arg(m_backupPath);
|
||||
m_isForce = true;
|
||||
if (m_p != nullptr)
|
||||
m_p->stop();
|
||||
// 10s钟后如果还没有退出,则强制退出
|
||||
QTimer::singleShot(10*1000, this, &UDiskSystemRestoreProxy::checkUdiskExists);
|
||||
m_isForce = true;
|
||||
} else {
|
||||
QTimer::singleShot(1*1000, this, &UDiskSystemRestoreProxy::checkUdiskExists);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue