删除日志记录错误

This commit is contained in:
zhaominyong 2022-03-10 15:59:33 +08:00
parent 8dbd01c6d5
commit 6e90bbffb3
6 changed files with 32 additions and 34 deletions

View File

@ -43,10 +43,6 @@ bool DeleteBackupProxy::deleteXmlBackupPoint()
ParseBackupList parse(xmlPath); ParseBackupList parse(xmlPath);
// 查询节点 // 查询节点
m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); 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) { if (parse.deleteItem(m_backupWrapper.m_uuid) != ParseBackupList::SUCCESS) {
@ -77,8 +73,8 @@ void DeleteBackupProxy::deleteBackupPointDir()
QProcess::execute("rm", args); QProcess::execute("rm", args);
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
if ( int(BackupType::BACKUP_DATA) == m_backupWrapper.m_type if ( int(BackupType::BACKUP_DATA) == m_backupPoint.m_type
|| int(BackupType::INC_BACKUP_DATA) == m_backupWrapper.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); Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName);
} else { } else {
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName); Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName);

View File

@ -89,6 +89,7 @@ void CalcBackupSize::parseResult()
*/ */
QString out(m_process->readAll()); QString out(m_process->readAll());
QStringList lines = out.split("\n"); QStringList lines = out.split("\n");
qDebug() << out;
for (QString& line : lines) { for (QString& line : lines) {
// 获取文件夹数目 // 获取文件夹数目
// if (line.startsWith("Number of files:")) { // if (line.startsWith("Number of files:")) {

View File

@ -165,6 +165,7 @@ void SystemBackupProxy::checkFreeCapacity(qint64 itotalSize)
backupPath.replace("//", "/"); backupPath.replace("//", "/");
QStorageInfo backupDisk(backupPath); QStorageInfo backupDisk(backupPath);
qint64 freeSize = backupDisk.bytesAvailable(); qint64 freeSize = backupDisk.bytesAvailable();
qDebug() << "需要空间" << itotalSize << ", 剩余空间" << freeSize;
// 3、校验空间是否足够 // 3、校验空间是否足够
if (itotalSize > freeSize) { if (itotalSize > freeSize) {

View File

@ -53,7 +53,7 @@
#define COLOR_YELLOW "#F8A34C" #define COLOR_YELLOW "#F8A34C"
#define COLOR_LIGHT_BLUE "#DDEBFF" #define COLOR_LIGHT_BLUE "#DDEBFF"
#define QT_USE_NAMESPACE_TEST using namespace Qt; #define END_LINE "\n"
/** /**
* @brief * @brief

View File

@ -27,8 +27,6 @@
#include "mylittleparse.h" #include "mylittleparse.h"
#include "mydefine.h" #include "mydefine.h"
QT_USE_NAMESPACE_TEST
QString SystemInfo::m_os; QString SystemInfo::m_os;
QString SystemInfo::m_arch; QString SystemInfo::m_arch;
QString SystemInfo::m_archDetect; QString SystemInfo::m_archDetect;
@ -97,7 +95,7 @@ void Utils::customMessageHandler(QtMsgType type, const QMessageLogContext& conte
QFile file(fileName); QFile file(fileName);
file.open(QIODevice::ReadWrite | QIODevice::Append); file.open(QIODevice::ReadWrite | QIODevice::Append);
QTextStream stream(&file); QTextStream stream(&file);
stream << strMessage << endl; stream << strMessage << END_LINE;
stream.flush(); stream.flush();
file.close(); file.close();
} }
@ -435,36 +433,37 @@ bool Utils::generateExcludePathsFile()
} }
QTextStream in(&excludePathFile); QTextStream in(&excludePathFile);
in << "/backup" << endl; //分区 in << "/backup" << END_LINE; //分区
// in << "/boot/efi" << endl; // in << "/boot/efi" << END_LINE;
in << "/cdrom" << endl; in << "/cdrom" << END_LINE;
in << "/dev" << endl; in << "/dev" << END_LINE;
// efi原始目录在/boot/efi备份到目标目录为/efi下再还原时已经单独处理了批量还原时应该屏蔽此目录 // efi原始目录在/boot/efi备份到目标目录为/efi下再还原时已经单独处理了批量还原时应该屏蔽此目录
in << "/efi" << endl; in << "/efi" << END_LINE;
// 安全模块会将文件/usr/share/kysec-utils/data/readonly_list中的文件列表限制只读无法修改、备份包含扩展属性时、删除等 // 安全模块会将文件/usr/share/kysec-utils/data/readonly_list中的文件列表限制只读无法修改、备份包含扩展属性时、删除等
// 现在里面仅有/etc/uid_list先暂时排除掉等后续安全模块有其它保护方案后再进一步修改 // 现在里面仅有/etc/uid_list先暂时排除掉等后续安全模块有其它保护方案后再进一步修改
in << "/etc/uid_list" << endl; in << "/etc/uid_list" << END_LINE;
in << "/ghost" << endl; //ghost镜像文件 in << "/data/ghost" << END_LINE; //ghost镜像文件
in << "/lost+found" << endl; in << "/ghost" << END_LINE; //ghost镜像文件
in << "/media" << endl; in << "/lost+found" << END_LINE;
in << "/mnt" << endl; in << "/media" << END_LINE;
in << "/proc" << endl; in << "/mnt" << END_LINE;
in << "/run" << endl; in << "/proc" << END_LINE;
in << "/swap_file" << endl; in << "/run" << END_LINE;
in << "/sys" << endl; //添加*(/sys/*),表示如果/sys目录不存在则会拷贝/sys但不会拷贝/sys下的内容 in << "/swap_file" << END_LINE;
in << "/tmp" << endl; in << "/sys" << END_LINE; //添加*(/sys/*),表示如果/sys目录不存在则会拷贝/sys但不会拷贝/sys下的内容
in << "/var/lib/docker/overlay2" << endl; in << "/tmp" << END_LINE;
in << "/var/lib/docker/overlay2" << END_LINE;
// 安卓兼容的这个里面很多文件都是设置了特殊扩展文件属性lsetxattr无法设置成功听取安卓兼容模块同事的意见不用管这个文件夹其实是从home下挂载的 // 安卓兼容的这个里面很多文件都是设置了特殊扩展文件属性lsetxattr无法设置成功听取安卓兼容模块同事的意见不用管这个文件夹其实是从home下挂载的
in << "/var/lib/kmre" << endl; in << "/var/lib/kmre" << END_LINE;
in << "/var/lib/udisks2" << endl; in << "/var/lib/udisks2" << END_LINE;
in << "/var/log" << endl; in << "/var/log" << END_LINE;
// 系统安装后有的会将/data/home /data/root挂载到的/home /root上实际文件是存放在/data/home /data/root下面为了统一标准保留/home /root排除/data/home /data/root // 系统安装后有的会将/data/home /data/root挂载到的/home /root上实际文件是存放在/data/home /data/root下面为了统一标准保留/home /root排除/data/home /data/root
QStringList excludes; QStringList excludes;
Utils::excludeFstabBindPath(excludes); Utils::excludeFstabBindPath(excludes);
Utils::excludeSomeHomePath(excludes); Utils::excludeSomeHomePath(excludes);
for (const QString& item : excludes) { for (const QString& item : excludes) {
in << item << endl; in << item << END_LINE;
} }
in.flush(); in.flush();
@ -498,6 +497,7 @@ QStringList Utils::getFromExcludePathsFile()
list << "/dev"; list << "/dev";
list << "/efi"; list << "/efi";
list << "/etc/uid_list"; list << "/etc/uid_list";
list << "/data/ghost";
list << "/ghost"; list << "/ghost";
list << "/lost+found"; list << "/lost+found";
list << "/media"; list << "/media";
@ -551,7 +551,7 @@ bool Utils::writeFileByLines(const QString& fileName, const QStringList& lines)
QTextStream out(&file); QTextStream out(&file);
for (const QString& line : lines) { for (const QString& line : lines) {
out << line << endl; out << line << END_LINE;
} }
out.flush(); out.flush();
file.close(); file.close();
@ -1181,7 +1181,7 @@ bool Utils::updateSyncFile()
} }
QTextStream out(&file); QTextStream out(&file);
out << "sync" << endl; out << "sync" << END_LINE;
file.close(); file.close();
return true; return true;

View File

@ -111,8 +111,8 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
} }
//hide factory backup //hide factory backup
if (backupPoint.m_uuid == FACTORY_BACKUP_UUID) // if (backupPoint.m_uuid == FACTORY_BACKUP_UUID)
continue; // continue;
//udisk unique //udisk unique
if (backupPoint.m_path.startsWith(preDevPath)) { if (backupPoint.m_path.startsWith(preDevPath)) {