diff --git a/backup-daemon/customizedatabackupproxy.cpp b/backup-daemon/customizedatabackupproxy.cpp index 19d7d77..0b8201f 100755 --- a/backup-daemon/customizedatabackupproxy.cpp +++ b/backup-daemon/customizedatabackupproxy.cpp @@ -60,6 +60,24 @@ bool CustomizeDataBackupProxy::checkEnvEx() 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、判断备份是否增量备份 isIncBackup(); diff --git a/backup-daemon/customizesystembackupproxy.cpp b/backup-daemon/customizesystembackupproxy.cpp index e2b69de..6f6ee97 100755 --- a/backup-daemon/customizesystembackupproxy.cpp +++ b/backup-daemon/customizesystembackupproxy.cpp @@ -65,6 +65,25 @@ bool CustomizeSystemBackupProxy::checkEnvEx() qCritical() << QString("dstDir %s is not exist!").arg(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、计算备份大小 calcSizeForBackup(); diff --git a/kybackup/module/databackup.cpp b/kybackup/module/databackup.cpp index 6b14912..11909db 100755 --- a/kybackup/module/databackup.cpp +++ b/kybackup/module/databackup.cpp @@ -480,16 +480,21 @@ void DataBackup::initSecondWidget() if (fileDialog.exec() == QDialog::Accepted) { QStringList selectFiles = fileDialog.selectedFiles(); if (!selectFiles.isEmpty()) { - comboSelect->setCurrentIndex(-1); 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; - comboSelect->setLineEdit(edit); - edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH); - edit->setReadOnly(true); - if (listWidget->getBackupPaths().size() > 0) - nextStep->setEnabled(true); + QLineEdit * edit = new QLineEdit; + comboSelect->setLineEdit(edit); + edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH); + edit->setReadOnly(true); + if (listWidget->getBackupPaths().size() > 0) + nextStep->setEnabled(true); + } } } }); diff --git a/kybackup/module/systembackup.cpp b/kybackup/module/systembackup.cpp index aa17b7f..9c123b4 100755 --- a/kybackup/module/systembackup.cpp +++ b/kybackup/module/systembackup.cpp @@ -336,15 +336,20 @@ void SystemBackup::initSecondWidget() if (fileDialog.exec() == QDialog::Accepted) { QStringList selectFiles = fileDialog.selectedFiles(); if (!selectFiles.isEmpty()) { - comboSelect->setCurrentIndex(-1); 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; - comboSelect->setLineEdit(edit); - edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH); - edit->setReadOnly(true); - nextStep->setEnabled(true); + QLineEdit * edit = new QLineEdit; + comboSelect->setLineEdit(edit); + edit->setText(tr("customize path : ") + fileName + BACKUP_SNAPSHOTS_PATH); + edit->setReadOnly(true); + nextStep->setEnabled(true); + } } } });