From 6e90bbffb37b1270000559fab2f86bd0582a4b0b Mon Sep 17 00:00:00 2001 From: zhaominyong Date: Thu, 10 Mar 2022 15:59:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A5=E5=BF=97=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup-daemon/deletebackupproxy.cpp | 8 +--- backup-daemon/myprocess/calcbackupsize.cpp | 1 + backup-daemon/systembackupproxy.cpp | 1 + common/mydefine.h | 2 +- common/utils.cpp | 50 +++++++++++----------- kybackup/module/managebackuppointlist.cpp | 4 +- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/backup-daemon/deletebackupproxy.cpp b/backup-daemon/deletebackupproxy.cpp index dae525b..b2a2ece 100755 --- a/backup-daemon/deletebackupproxy.cpp +++ b/backup-daemon/deletebackupproxy.cpp @@ -43,10 +43,6 @@ bool DeleteBackupProxy::deleteXmlBackupPoint() ParseBackupList parse(xmlPath); // 查询节点 m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); - if ( int(BackupType::BACKUP_DATA) != m_backupPoint.m_type - && int(BackupType::INC_BACKUP_DATA) != m_backupPoint.m_type) { - m_backupWrapper.m_type = m_backupPoint.m_type; - } // 删除节点 if (parse.deleteItem(m_backupWrapper.m_uuid) != ParseBackupList::SUCCESS) { @@ -77,8 +73,8 @@ void DeleteBackupProxy::deleteBackupPointDir() QProcess::execute("rm", args); QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); - if ( int(BackupType::BACKUP_DATA) == m_backupWrapper.m_type - || int(BackupType::INC_BACKUP_DATA) == m_backupWrapper.m_type) { + if ( int(BackupType::BACKUP_DATA) == m_backupPoint.m_type + || int(BackupType::INC_BACKUP_DATA) == m_backupPoint.m_type) { Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName); } else { Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName); diff --git a/backup-daemon/myprocess/calcbackupsize.cpp b/backup-daemon/myprocess/calcbackupsize.cpp index da53f96..f737e17 100755 --- a/backup-daemon/myprocess/calcbackupsize.cpp +++ b/backup-daemon/myprocess/calcbackupsize.cpp @@ -89,6 +89,7 @@ void CalcBackupSize::parseResult() */ QString out(m_process->readAll()); QStringList lines = out.split("\n"); + qDebug() << out; for (QString& line : lines) { // 获取文件夹数目 // if (line.startsWith("Number of files:")) { diff --git a/backup-daemon/systembackupproxy.cpp b/backup-daemon/systembackupproxy.cpp index ae9a9e4..6ecf8cb 100755 --- a/backup-daemon/systembackupproxy.cpp +++ b/backup-daemon/systembackupproxy.cpp @@ -165,6 +165,7 @@ void SystemBackupProxy::checkFreeCapacity(qint64 itotalSize) backupPath.replace("//", "/"); QStorageInfo backupDisk(backupPath); qint64 freeSize = backupDisk.bytesAvailable(); + qDebug() << "需要空间" << itotalSize << ", 剩余空间" << freeSize; // 3、校验空间是否足够 if (itotalSize > freeSize) { diff --git a/common/mydefine.h b/common/mydefine.h index 8ff6fe6..e821015 100755 --- a/common/mydefine.h +++ b/common/mydefine.h @@ -53,7 +53,7 @@ #define COLOR_YELLOW "#F8A34C" #define COLOR_LIGHT_BLUE "#DDEBFF" -#define QT_USE_NAMESPACE_TEST using namespace Qt; +#define END_LINE "\n" /** * @brief 备份还原操作类型 diff --git a/common/utils.cpp b/common/utils.cpp index afb46d9..2258bfb 100755 --- a/common/utils.cpp +++ b/common/utils.cpp @@ -27,8 +27,6 @@ #include "mylittleparse.h" #include "mydefine.h" -QT_USE_NAMESPACE_TEST - QString SystemInfo::m_os; QString SystemInfo::m_arch; QString SystemInfo::m_archDetect; @@ -97,7 +95,7 @@ void Utils::customMessageHandler(QtMsgType type, const QMessageLogContext& conte QFile file(fileName); file.open(QIODevice::ReadWrite | QIODevice::Append); QTextStream stream(&file); - stream << strMessage << endl; + stream << strMessage << END_LINE; stream.flush(); file.close(); } @@ -435,36 +433,37 @@ bool Utils::generateExcludePathsFile() } QTextStream in(&excludePathFile); - in << "/backup" << endl; //分区 - // in << "/boot/efi" << endl; - in << "/cdrom" << endl; - in << "/dev" << endl; + in << "/backup" << END_LINE; //分区 + // in << "/boot/efi" << END_LINE; + in << "/cdrom" << END_LINE; + in << "/dev" << END_LINE; // efi原始目录在/boot/efi,备份到目标目录为/efi下,再还原时已经单独处理了,批量还原时应该屏蔽此目录 - in << "/efi" << endl; + in << "/efi" << END_LINE; // 安全模块会将文件/usr/share/kysec-utils/data/readonly_list中的文件列表限制只读,无法修改、备份(包含扩展属性时)、删除等 // 现在里面仅有/etc/uid_list,先暂时排除掉;等后续安全模块有其它保护方案后再进一步修改 - in << "/etc/uid_list" << endl; - in << "/ghost" << endl; //ghost镜像文件 - in << "/lost+found" << endl; - in << "/media" << endl; - in << "/mnt" << endl; - in << "/proc" << endl; - in << "/run" << endl; - in << "/swap_file" << endl; - in << "/sys" << endl; //添加*(/sys/*),表示如果/sys目录不存在,则会拷贝/sys,但不会拷贝/sys下的内容 - in << "/tmp" << endl; - in << "/var/lib/docker/overlay2" << endl; + in << "/etc/uid_list" << END_LINE; + in << "/data/ghost" << END_LINE; //ghost镜像文件 + in << "/ghost" << END_LINE; //ghost镜像文件 + in << "/lost+found" << END_LINE; + in << "/media" << END_LINE; + in << "/mnt" << END_LINE; + in << "/proc" << END_LINE; + in << "/run" << END_LINE; + in << "/swap_file" << END_LINE; + in << "/sys" << END_LINE; //添加*(/sys/*),表示如果/sys目录不存在,则会拷贝/sys,但不会拷贝/sys下的内容 + in << "/tmp" << END_LINE; + in << "/var/lib/docker/overlay2" << END_LINE; // 安卓兼容的这个里面很多文件都是设置了特殊扩展文件属性,lsetxattr无法设置成功,听取安卓兼容模块同事的意见不用管这个文件夹,其实是从home下挂载的 - in << "/var/lib/kmre" << endl; - in << "/var/lib/udisks2" << endl; - in << "/var/log" << endl; + in << "/var/lib/kmre" << END_LINE; + in << "/var/lib/udisks2" << END_LINE; + in << "/var/log" << END_LINE; // 系统安装后有的会将/data/home /data/root挂载到的/home /root上,实际文件是存放在/data/home /data/root下面,为了统一标准保留/home /root排除/data/home /data/root QStringList excludes; Utils::excludeFstabBindPath(excludes); Utils::excludeSomeHomePath(excludes); for (const QString& item : excludes) { - in << item << endl; + in << item << END_LINE; } in.flush(); @@ -498,6 +497,7 @@ QStringList Utils::getFromExcludePathsFile() list << "/dev"; list << "/efi"; list << "/etc/uid_list"; + list << "/data/ghost"; list << "/ghost"; list << "/lost+found"; list << "/media"; @@ -551,7 +551,7 @@ bool Utils::writeFileByLines(const QString& fileName, const QStringList& lines) QTextStream out(&file); for (const QString& line : lines) { - out << line << endl; + out << line << END_LINE; } out.flush(); file.close(); @@ -1181,7 +1181,7 @@ bool Utils::updateSyncFile() } QTextStream out(&file); - out << "sync" << endl; + out << "sync" << END_LINE; file.close(); return true; diff --git a/kybackup/module/managebackuppointlist.cpp b/kybackup/module/managebackuppointlist.cpp index c5f9be3..5f34ac4 100755 --- a/kybackup/module/managebackuppointlist.cpp +++ b/kybackup/module/managebackuppointlist.cpp @@ -111,8 +111,8 @@ void ManageBackupPointList::insertLines(const QList