diff --git a/backup-daemon/mybackupmanager.cpp b/backup-daemon/mybackupmanager.cpp index d2cb59f..9889980 100755 --- a/backup-daemon/mybackupmanager.cpp +++ b/backup-daemon/mybackupmanager.cpp @@ -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) { diff --git a/backup-daemon/myprocess/mksquashfsprocess.cpp b/backup-daemon/myprocess/mksquashfsprocess.cpp index bbc0a75..1b7c367 100644 --- a/backup-daemon/myprocess/mksquashfsprocess.cpp +++ b/backup-daemon/myprocess/mksquashfsprocess.cpp @@ -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); diff --git a/backup-daemon/udisksystembackupproxy.cpp b/backup-daemon/udisksystembackupproxy.cpp index f21595f..b868cde 100644 --- a/backup-daemon/udisksystembackupproxy.cpp +++ b/backup-daemon/udisksystembackupproxy.cpp @@ -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); }