Skip to content

Commit

Permalink
fix: 解决导出崩溃日志失败的问题
Browse files Browse the repository at this point in the history
  仅有coredump文件才从标准输出读取压缩进度,其他时候不读取。

Log: 解决导出崩溃日志失败的问题
Bug: https://pms.uniontech.com/bug-view-217019.html
  • Loading branch information
starhcq committed Aug 30, 2023
1 parent 9abd946 commit 1914aa4
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions application/logexportthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3359,8 +3359,11 @@ bool LogExportThread::exportToZip(const QString &fileName, const QList<LOG_MSG_C
Utils::mkMutiDir(tmpPath);

//复制文件
int nCoreDumpCount = 0;
for (auto &it : jList) {
DLDBusHandler::instance(this)->exportLog(tmpPath, it.storagePath, true);
if (it.coreFile == "present")
nCoreDumpCount++;
if (!m_canRunning) {
break;
}
Expand All @@ -3378,26 +3381,31 @@ bool LogExportThread::exportToZip(const QString &fileName, const QList<LOG_MSG_C

// refresh progress
bool ret = false;
connect(&procss, &QProcess::readyReadStandardOutput, this, [&](){
if (!m_canRunning) {
procss.kill();
ret = false;
qDebug() << "route process slot can't run.. ret:" << ret;
return;
}

QByteArray dd = procss.readAllStandardOutput();
QList<QString> lines = QString(dd).split('\n', QString::SkipEmptyParts);
for (const QString &line : qAsConst(lines)) {
int pos = line.indexOf(QLatin1Char('%'));
if (pos > 1) {
int percentage = line.midRef(pos - 3, 3).toInt();
sigProgress(percentage, 100);
// 有coredump文件,才读取压缩进度
if (nCoreDumpCount > 0) {
connect(&procss, &QProcess::readyReadStandardOutput, this, [&](){
if (!m_canRunning) {
procss.kill();
ret = false;
return;
}
}

qInfo() << "recive proces done..";
QByteArray dd = procss.readAllStandardOutput();
QList<QString> lines = QString(dd).split('\n', QString::SkipEmptyParts);
for (const QString &line : qAsConst(lines)) {
int pos = line.indexOf(QLatin1Char('%'));
if (pos > 1) {
int percentage = line.midRef(pos - 3, 3).toInt();
sigProgress(percentage, 100);
}
}
ret = true;
});
} else {
ret = true;
qDebug() << "route process slot ret:" << ret;
});
}

procss.start("/bin/bash", arg);
procss.waitForFinished(-1);

Expand Down

0 comments on commit 1914aa4

Please sign in to comment.