133526 【备份还原工具】vfat格式的U盘能够作为备份路径进行 备份还原操作

This commit is contained in:
zhaominyong 2022-08-05 10:26:18 +08:00
parent c506d62d13
commit ae545075fc
4 changed files with 62 additions and 15 deletions

View File

@ -60,6 +60,24 @@ bool CustomizeDataBackupProxy::checkEnvEx()
Utils::mkpath(m_backupWrapper.m_prefixDestPath); Utils::mkpath(m_backupWrapper.m_prefixDestPath);
} }
// 因为有可能是选择的移动设备,故进行校验移动设备情况:空间大小、文件格式、挂载模式等
QString backupPath(m_backupWrapper.m_prefixDestPath);
backupPath.replace("//", "/");
QStorageInfo udisk(backupPath);
QString udisk_type = udisk.fileSystemType();
qDebug() << "udisk's filesystemtype is " << udisk_type;
if (udisk_type == "vfat") {
qCritical() << m_backupWrapper.m_prefixDestPath + " udisk's filesystemtype is vfat";
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_TYPE_IS_VFAT));
return false;
}
if (udisk.isReadOnly()) {
// 只读挂载的U盘
qCritical() << QString("udisk(%s) is readonly filesystem").arg(m_backupWrapper.m_prefixDestPath);
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_IS_READONLY));
return false;
}
// 2、判断备份是否增量备份 // 2、判断备份是否增量备份
isIncBackup(); isIncBackup();

View File

@ -65,6 +65,25 @@ bool CustomizeSystemBackupProxy::checkEnvEx()
qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath); qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath);
Utils::mkpath(m_backupWrapper.m_prefixDestPath); Utils::mkpath(m_backupWrapper.m_prefixDestPath);
} }
// 因为有可能是选择的移动设备,故进行校验移动设备情况:空间大小、文件格式、挂载模式等
QString backupPath(m_backupWrapper.m_prefixDestPath);
backupPath.replace("//", "/");
QStorageInfo udisk(backupPath);
QString udisk_type = udisk.fileSystemType();
qDebug() << "udisk's filesystemtype is " << udisk_type;
if (udisk_type == "vfat") {
qCritical() << m_backupWrapper.m_prefixDestPath + " udisk's filesystemtype is vfat";
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_TYPE_IS_VFAT));
return false;
}
if (udisk.isReadOnly()) {
// 只读挂载的U盘
qCritical() << QString("udisk(%s) is readonly filesystem").arg(m_backupWrapper.m_prefixDestPath);
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_IS_READONLY));
return false;
}
// 2、计算备份大小 // 2、计算备份大小
calcSizeForBackup(); calcSizeForBackup();

View File

@ -480,8 +480,12 @@ void DataBackup::initSecondWidget()
if (fileDialog.exec() == QDialog::Accepted) { if (fileDialog.exec() == QDialog::Accepted) {
QStringList selectFiles = fileDialog.selectedFiles(); QStringList selectFiles = fileDialog.selectedFiles();
if (!selectFiles.isEmpty()) { if (!selectFiles.isEmpty()) {
comboSelect->setCurrentIndex(-1);
QString fileName = selectFiles.at(0); QString fileName = selectFiles.at(0);
if (this->m_udiskPaths.contains(fileName)) {
comboSelect->setCurrentIndex(this->m_udiskPaths.indexOf(fileName));
this->m_customizePath = "";
} else {
comboSelect->setCurrentIndex(-1);
this->m_customizePath = fileName; this->m_customizePath = fileName;
QLineEdit * edit = new QLineEdit; QLineEdit * edit = new QLineEdit;
@ -492,6 +496,7 @@ void DataBackup::initSecondWidget()
nextStep->setEnabled(true); nextStep->setEnabled(true);
} }
} }
}
}); });
connect(nextStep, &MyPushButton::clicked, this, [=]() { connect(nextStep, &MyPushButton::clicked, this, [=]() {
// 备份路径选择索引 // 备份路径选择索引

View File

@ -336,8 +336,12 @@ void SystemBackup::initSecondWidget()
if (fileDialog.exec() == QDialog::Accepted) { if (fileDialog.exec() == QDialog::Accepted) {
QStringList selectFiles = fileDialog.selectedFiles(); QStringList selectFiles = fileDialog.selectedFiles();
if (!selectFiles.isEmpty()) { if (!selectFiles.isEmpty()) {
comboSelect->setCurrentIndex(-1);
QString fileName = selectFiles.at(0); QString fileName = selectFiles.at(0);
if (this->m_udiskPaths.contains(fileName)) {
comboSelect->setCurrentIndex(this->m_udiskPaths.indexOf(fileName));
this->m_customizePath = "";
} else {
comboSelect->setCurrentIndex(-1);
this->m_customizePath = fileName; this->m_customizePath = fileName;
QLineEdit * edit = new QLineEdit; QLineEdit * edit = new QLineEdit;
@ -347,6 +351,7 @@ void SystemBackup::initSecondWidget()
nextStep->setEnabled(true); nextStep->setEnabled(true);
} }
} }
}
}); });
connect(nextStep, &MyPushButton::clicked, this, [=](bool checked) { connect(nextStep, &MyPushButton::clicked, this, [=](bool checked) {
// 备份路径选择索引 // 备份路径选择索引