bug修复

This commit is contained in:
zhaominyong 2021-09-01 15:46:24 +08:00
parent dba7168325
commit f555fe5c20
5 changed files with 50 additions and 1 deletions

View File

@ -31,6 +31,7 @@ int main(int argc, char *argv[])
qDebug() << QString("测试 begin");
BackupWrapper backupWrapper;
backupWrapper.m_backupName = "赵民勇test";
backupWrapper.m_backupPaths << "/";
backupWrapper.m_backupExcludePaths = Utils::getFromExcludePathsFile();
MyBackupManager manager;
manager.goBackup(backupWrapper);

View File

@ -80,6 +80,7 @@ void RsyncPathToDirProcess::processFinished(int exitCode, QProcess::ExitStatus)
if (exitCode == QProcess::NormalExit || exitCode == 24 || exitCode == 23) {
sync();
m_bSuccess = true;
emit progress(100);
emit finished(true);
} else {
emit finished(false);

View File

@ -385,7 +385,46 @@ ParseBackupList::ParseResult ParseBackupList::updateItem(const BackupPoint & bac
}
QFile xmlFile(m_xmlPath);
if (!xmlFile.open(QIODevice::WriteOnly)) {
if (!xmlFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
return FAIL;
}
QTextStream out(&xmlFile);
doc.save(out, QDomNode::NodeType::EntityReferenceNode);
xmlFile.close();
return SUCCESS;
}
/**
* @brief
* @param uuid
* @return SUCCESS成功 XML_PARSE_ERR失败
*/
ParseBackupList::ParseResult ParseBackupList::deleteItem(const QString& uuid)
{
QDomDocument doc;
if (!Doc_setContent(doc))
return XML_PARSE_ERR;
QDomElement root = doc.documentElement();
QDomNodeList list = root.childNodes();
for (int i = 0; i < list.count(); i++) {
QDomNode node = list.at(i);
if (!node.isElement())
continue;
QDomElement eleUuid = node.firstChildElement(UUID);
if (eleUuid.isNull() || uuid != eleUuid.text())
continue;
root.removeChild(node);
break ;
}
QFile xmlFile(m_xmlPath);
if (!xmlFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
return FAIL;
}

View File

@ -81,6 +81,13 @@ public:
*/
ParseResult updateItem(const BackupPoint & backupPoint);
/**
* @brief
* @param uuid
* @return SUCCESS成功 XML_PARSE_ERR失败
*/
ParseResult deleteItem(const QString& uuid);
inline QString getXmlPath() { return m_xmlPath; }
private:

View File

@ -88,6 +88,7 @@ bool SystemBackupProxy::isIncBackup()
if (Utils::isDirExist(backupPath)) {
m_backupWrapper.m_baseUuid = point.m_uuid;
m_backupWrapper.m_bIncrement = true;
m_backupWrapper.m_type = BackupType::INC_BACKUP_SYSTEM;
return true;
}
return false;