Skip to content

Commit

Permalink
fix: ix cli export to no-write dir can not quit
Browse files Browse the repository at this point in the history
  ix cli export to no-write dir can not quit

Log: ix cli export to no-write dir can not quit
Bug: https://pms.uniontech.com/bug-view-225553.html
  • Loading branch information
starhcq committed Oct 26, 2023
1 parent 9a7c693 commit 02c48b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions application/logbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void LogBackend::setCmdWorkDir(const QString &dirPath)
m_cmdWorkDir = dirPath;
}

void LogBackend::exportAllLogs(const QString &outDir)
int LogBackend::exportAllLogs(const QString &outDir)
{
if(!getOutDirPath(outDir))
return;
return -1;

PERF_PRINT_BEGIN("POINT-05", "export all logs");
qCInfo(logBackend) << "exporting all logs begin.";
Expand Down Expand Up @@ -100,6 +100,8 @@ void LogBackend::exportAllLogs(const QString &outDir)
QThreadPool::globalInstance()->start(thread);

Utils::resetToNormalAuth(m_outPath);

return 0;
}

int LogBackend::exportTypeLogs(const QString &outDir, const QString &type)
Expand Down Expand Up @@ -1434,7 +1436,7 @@ bool LogBackend::getOutDirPath(const QString &path)
if (dir.exists()) {
QFileInfo fi(tmpPath);
if (!fi.isWritable()) {
qCWarning(logBackend) << "outPath: isnot writable." << m_outPath;
qCWarning(logBackend) << QString("outPath: %1 is not writable.").arg(tmpPath);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion application/logbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LogBackend : public QObject
void setCmdWorkDir(const QString &dirPath);

// 导出全部日志到指定目录
void exportAllLogs(const QString &outDir = "");
int exportAllLogs(const QString &outDir = "");

// 按类型导出日志
int exportTypeLogs(const QString &outDir, const QString &type = "");
Expand Down
4 changes: 3 additions & 1 deletion application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ int main(int argc, char *argv[])
return -1;
}
// 未指定类型,默认导出所有日志
LogBackend::instance(&a)->exportAllLogs(outDir);
int nRet = LogBackend::instance(&a)->exportAllLogs(outDir);
if (nRet != 0)
return nRet;
}

return a.exec();
Expand Down

0 comments on commit 02c48b4

Please sign in to comment.