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,16 +480,21 @@ 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);
this->m_customizePath = fileName; if (this->m_udiskPaths.contains(fileName)) {
comboSelect->setCurrentIndex(this->m_udiskPaths.indexOf(fileName));
this->m_customizePath = "";
} else {
comboSelect->setCurrentIndex(-1);
this->m_customizePath = fileName;
QLineEdit * edit = new QLineEdit; QLineEdit * edit = new QLineEdit;
comboSelect->setLineEdit(edit); comboSelect->setLineEdit(edit);
edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH); edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH);
edit->setReadOnly(true); edit->setReadOnly(true);
if (listWidget->getBackupPaths().size() > 0) if (listWidget->getBackupPaths().size() > 0)
nextStep->setEnabled(true); nextStep->setEnabled(true);
}
} }
} }
}); });

View File

@ -336,15 +336,20 @@ 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);
this->m_customizePath = fileName; if (this->m_udiskPaths.contains(fileName)) {
comboSelect->setCurrentIndex(this->m_udiskPaths.indexOf(fileName));
this->m_customizePath = "";
} else {
comboSelect->setCurrentIndex(-1);
this->m_customizePath = fileName;
QLineEdit * edit = new QLineEdit; QLineEdit * edit = new QLineEdit;
comboSelect->setLineEdit(edit); comboSelect->setLineEdit(edit);
edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH); edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH);
edit->setReadOnly(true); edit->setReadOnly(true);
nextStep->setEnabled(true); nextStep->setEnabled(true);
}
} }
} }
}); });