修改测试出的问题

This commit is contained in:
zhaominyong 2021-11-20 17:48:23 +08:00
parent 46bb97df33
commit 24d1f53f37
3 changed files with 28 additions and 5 deletions

View File

@ -124,10 +124,15 @@ int MyBackupManager::goBackup(const BackupWrapper& backupWrapper)
worker->setParam(backupWrapper); worker->setParam(backupWrapper);
connect(worker, &Worker::checkResult, this, [&](int result) { connect(worker, &Worker::checkResult, this, [&](int result) {
emit this->sendEnvCheckResult(result); emit this->sendEnvCheckResult(result);
if ( result != int(BackupResult::CHECK_ENV_SUCCESS)
|| result != int(BackupResult::MKSQUASHFS_START_SUCCESS) switch (result) {
|| result != int(BackupResult::BACKUP_START_SUCCESS)) { case int(BackupResult::CHECK_ENV_SUCCESS) :
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
case int(BackupResult::BACKUP_START_SUCCESS) :
break;
default:
this->finished(); this->finished();
break;
} }
}); });
connect(worker, &Worker::progress, this, [&](int rate) { connect(worker, &Worker::progress, this, [&](int rate) {

View File

@ -8,6 +8,7 @@ MkSquashFSProcess::MkSquashFSProcess(QObject* parent)
{ {
connect(m_p, &QProcess::readyRead, this, [&]() { connect(m_p, &QProcess::readyRead, this, [&]() {
QString str = QString(m_p->readAll()); QString str = QString(m_p->readAll());
qDebug() << str;
if (str.contains("]") && str.contains("%")) { if (str.contains("]") && str.contains("%")) {
if (str.split("%").at(0).length() < 3) if (str.split("%").at(0).length() < 3)
return; return;
@ -51,6 +52,13 @@ MkSquashFSProcess::~MkSquashFSProcess()
bool MkSquashFSProcess::start(const QStringList &args) bool MkSquashFSProcess::start(const QStringList &args)
{ {
QString cmd("mksquashfs ");
for (const QString& item : args) {
cmd += " ";
cmd += item;
}
qDebug() << cmd;
m_p->start("mksquashfs", args); m_p->start("mksquashfs", args);
if (!m_p->waitForStarted()) { if (!m_p->waitForStarted()) {
qCritical("mksquashfs start failed!"); qCritical("mksquashfs start failed!");
@ -75,6 +83,7 @@ void MkSquashFSProcess::mksquashfs_finished(int exitCode, QProcess::ExitStatus)
void MkSquashFSProcess::sync_finished(int exitCode, QProcess::ExitStatus) void MkSquashFSProcess::sync_finished(int exitCode, QProcess::ExitStatus)
{ {
if (exitCode == QProcess::NormalExit) { if (exitCode == QProcess::NormalExit) {
emit progress(100);
emit finished(true); emit finished(true);
} else { } else {
emit finished(false); emit finished(false);

View File

@ -220,8 +220,14 @@ QStringList UDiskSystemBackupProxy::getRsyncArgs(UDiskSystemBackupScene scene)
args << "-e" << item; args << "-e" << item;
} }
args << "-e" << m_imgPath;
return args; return args;
case UDiskSystemBackupScene::IMG_BACKUP : case UDiskSystemBackupScene::IMG_BACKUP :
args << "-avAHXr";
args << "--info=progress2";
args << "--no-inc-recursive";
args << "--ignore-missing-args";
return args;
default: default:
return args; return args;
} }
@ -242,6 +248,7 @@ void UDiskSystemBackupProxy::doMksqushfs()
qDebug() << "UDiskSystemBackupProxy::doMksqushfs invoke begin"; qDebug() << "UDiskSystemBackupProxy::doMksqushfs invoke begin";
m_mksquashfs = new MkSquashFSProcess(this); m_mksquashfs = new MkSquashFSProcess(this);
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskSystemBackupProxy::progress);
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [=](bool result) { connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [=](bool result) {
if (result) { if (result) {
// 开始备份 // 开始备份
@ -260,7 +267,9 @@ void UDiskSystemBackupProxy::doMksqushfs()
args << srcPath << dstImg; args << srcPath << dstImg;
args.append(getRsyncArgs(UDiskSystemBackupScene::MKSQUASHFS)); args.append(getRsyncArgs(UDiskSystemBackupScene::MKSQUASHFS));
if (!m_mksquashfs->start(args)) { if (m_mksquashfs->start(args)) {
emit checkResult(int(BackupResult::MKSQUASHFS_START_SUCCESS));
} else {
emit checkResult(int(BackupResult::MKSQUASHFS_DO_FAIL)); emit checkResult(int(BackupResult::MKSQUASHFS_DO_FAIL));
} }
@ -413,7 +422,7 @@ bool UDiskSystemBackupProxy::backupImg()
QString srcPath = m_imgPath + "/" + UDISK_MKSQUASHFS_IMG_NAME; QString srcPath = m_imgPath + "/" + UDISK_MKSQUASHFS_IMG_NAME;
QString destPath = m_destPath + "/"; QString destPath = m_destPath + "/";
destPath.replace("//", "/"); destPath.replace("//", "/");
args << destPath; args << srcPath << destPath;
return backup(args); return backup(args);
} }