2021-08-06 10:20:03 +08:00
|
|
|
#include <QtDebug>
|
|
|
|
#include <QDir>
|
|
|
|
#include "mymountproxy.h"
|
|
|
|
#include "../common/utils.h"
|
|
|
|
|
|
|
|
MyMountProxy::MyMountProxy(QObject* parent) : QObject(parent)
|
|
|
|
{
|
|
|
|
m_processMount = new MountBackupProcess(this);
|
|
|
|
}
|
|
|
|
|
2021-10-26 09:24:05 +08:00
|
|
|
MountResult MyMountProxy::mountBackupPartition()
|
2021-08-06 10:20:03 +08:00
|
|
|
{
|
|
|
|
QString backupPartitionUuid = Utils::getBackupPartitionUuid();
|
|
|
|
if (backupPartitionUuid.isEmpty()) {
|
|
|
|
qCritical("can't open /etc/.bootinfo or can't get RECOVERY_DEV_UUID");
|
2021-10-26 09:24:05 +08:00
|
|
|
return MountResult::CANNOT_GET_BACKUPUUID;
|
2021-08-06 10:20:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QString rootPath = Utils::getSysRootPath();
|
|
|
|
QString backPath = rootPath + BACKUP_PATH;
|
|
|
|
backPath.replace("//", "/");
|
|
|
|
Utils::mkpath(backPath);
|
|
|
|
|
|
|
|
bool res = m_processMount->Do(backupPartitionUuid);
|
|
|
|
if (res) {
|
|
|
|
QString snapshotsPath = rootPath + BACKUP_SNAPSHOTS_PATH;
|
|
|
|
snapshotsPath.replace("//", "/");
|
|
|
|
Utils::mkpath(snapshotsPath);
|
|
|
|
|
|
|
|
if (!Utils::generateExcludePathsFile()) {
|
|
|
|
qCritical("mount success, but generate some important file failed!");
|
2021-10-26 09:24:05 +08:00
|
|
|
return MountResult::GENERATE_IMPORT_FILE_FAIL;
|
2021-08-06 10:20:03 +08:00
|
|
|
}
|
|
|
|
|
2021-10-26 09:24:05 +08:00
|
|
|
return MountResult::MOUNTED;
|
2021-08-06 10:20:03 +08:00
|
|
|
}
|
|
|
|
|
2021-10-26 09:24:05 +08:00
|
|
|
return MountResult::NO_MOUNTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MyMountProxy::umountBackupPartition()
|
|
|
|
{
|
|
|
|
return m_processMount->umountBackupPartition();
|
2021-08-06 10:20:03 +08:00
|
|
|
}
|
|
|
|
|