Merge branch 'master' of gitlab2.kylin.com:kylin-desktop/kylin-backup-tools/kylin-backup-tools-4.0.14
This commit is contained in:
commit
984157a251
|
@ -124,10 +124,15 @@ int MyBackupManager::goBackup(const BackupWrapper& backupWrapper)
|
|||
worker->setParam(backupWrapper);
|
||||
connect(worker, &Worker::checkResult, this, [&](int result) {
|
||||
emit this->sendEnvCheckResult(result);
|
||||
if ( result != int(BackupResult::CHECK_ENV_SUCCESS)
|
||||
|| result != int(BackupResult::MKSQUASHFS_START_SUCCESS)
|
||||
|| result != int(BackupResult::BACKUP_START_SUCCESS)) {
|
||||
|
||||
switch (result) {
|
||||
case int(BackupResult::CHECK_ENV_SUCCESS) :
|
||||
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
|
||||
case int(BackupResult::BACKUP_START_SUCCESS) :
|
||||
break;
|
||||
default:
|
||||
this->finished();
|
||||
break;
|
||||
}
|
||||
});
|
||||
connect(worker, &Worker::progress, this, [&](int rate) {
|
||||
|
|
|
@ -8,6 +8,7 @@ MkSquashFSProcess::MkSquashFSProcess(QObject* parent)
|
|||
{
|
||||
connect(m_p, &QProcess::readyRead, this, [&]() {
|
||||
QString str = QString(m_p->readAll());
|
||||
qDebug() << str;
|
||||
if (str.contains("]") && str.contains("%")) {
|
||||
if (str.split("%").at(0).length() < 3)
|
||||
return;
|
||||
|
@ -51,6 +52,13 @@ MkSquashFSProcess::~MkSquashFSProcess()
|
|||
|
||||
bool MkSquashFSProcess::start(const QStringList &args)
|
||||
{
|
||||
QString cmd("mksquashfs ");
|
||||
for (const QString& item : args) {
|
||||
cmd += " ";
|
||||
cmd += item;
|
||||
}
|
||||
qDebug() << cmd;
|
||||
|
||||
m_p->start("mksquashfs", args);
|
||||
if (!m_p->waitForStarted()) {
|
||||
qCritical("mksquashfs start failed!");
|
||||
|
@ -75,6 +83,7 @@ void MkSquashFSProcess::mksquashfs_finished(int exitCode, QProcess::ExitStatus)
|
|||
void MkSquashFSProcess::sync_finished(int exitCode, QProcess::ExitStatus)
|
||||
{
|
||||
if (exitCode == QProcess::NormalExit) {
|
||||
emit progress(100);
|
||||
emit finished(true);
|
||||
} else {
|
||||
emit finished(false);
|
||||
|
|
|
@ -220,8 +220,14 @@ QStringList UDiskSystemBackupProxy::getRsyncArgs(UDiskSystemBackupScene scene)
|
|||
|
||||
args << "-e" << item;
|
||||
}
|
||||
args << "-e" << m_imgPath;
|
||||
return args;
|
||||
case UDiskSystemBackupScene::IMG_BACKUP :
|
||||
args << "-avAHXr";
|
||||
args << "--info=progress2";
|
||||
args << "--no-inc-recursive";
|
||||
args << "--ignore-missing-args";
|
||||
return args;
|
||||
default:
|
||||
return args;
|
||||
}
|
||||
|
@ -242,6 +248,7 @@ void UDiskSystemBackupProxy::doMksqushfs()
|
|||
qDebug() << "UDiskSystemBackupProxy::doMksqushfs invoke begin";
|
||||
|
||||
m_mksquashfs = new MkSquashFSProcess(this);
|
||||
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskSystemBackupProxy::progress);
|
||||
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [=](bool result) {
|
||||
if (result) {
|
||||
// 开始备份
|
||||
|
@ -260,7 +267,9 @@ void UDiskSystemBackupProxy::doMksqushfs()
|
|||
args << srcPath << dstImg;
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -413,7 +422,7 @@ bool UDiskSystemBackupProxy::backupImg()
|
|||
QString srcPath = m_imgPath + "/" + UDISK_MKSQUASHFS_IMG_NAME;
|
||||
QString destPath = m_destPath + "/";
|
||||
destPath.replace("//", "/");
|
||||
args << destPath;
|
||||
args << srcPath << destPath;
|
||||
|
||||
return backup(args);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue