Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 解决导出崩溃日志失败的问题 #180

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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