Skip to content

Fix: [ops-log] Log file missing. - #411

Closed
GongHeng2017 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
GongHeng2017:upstream/release/eagle
Closed

GongHeng2017 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
GongHeng2017:upstream/release/eagle

Conversation

@GongHeng2017

Copy link
Copy Markdown
Contributor

-- some platform not export system_info.txt

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-335855.html

-- some platform not export system_info.txt

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-335855.html
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

这段代码是关于DLDBusHandler类中exportOpsLog方法的DBus调用部分。让我对这段代码进行审查:

  1. 语法逻辑:
  • 语法正确,没有语法错误
  • 代码逻辑清晰,通过DBus发送消息并检查响应类型
  1. 代码质量:
  • 使用了Qt的DBus功能,符合Qt编程规范
  • 有适当的错误处理和日志记录
  • 变量命名规范,可读性好
  1. 代码性能:
  • 添加了超时参数(1200000毫秒,即20分钟),这是一个改进
  • 使用了阻塞调用(Block),这在处理耗时操作时是合理的
  1. 代码安全:
  • 超时设置可以防止无限等待
  • 对错误消息进行了处理和记录

改进建议:

  1. 超时时间常量化:
const int EXPORT_OPS_LOG_TIMEOUT_MS = 1200000;
// ...
QDBusMessage reply = QDBusConnection::systemBus().call(message, QDBus::Block, EXPORT_OPS_LOG_TIMEOUT_MS);
  1. 考虑添加更多的错误检查:
if (reply.type() == QDBusMessage::ErrorMessage) {
    qCritical(logDBusHandler) << "call dbus interface 'exportHwOpsLog' failed. error info:" << reply.errorMessage();
    return false;
} else if (reply.type() == QDBusMessage::InvalidMessage) {
    qCritical(logDBusHandler) << "Received invalid D-Bus reply";
    return false;
}
  1. 考虑添加返回值检查(如果DBus调用应该返回特定值):
if (reply.type() == QDBusMessage::ReplyMessage) {
    // 检查返回值是否符合预期
    if (reply.arguments().isEmpty()) {
        qWarning(logDBusHandler) << "DBus call returned no arguments";
        return false;
    }
    // 处理返回值...
}
  1. 考虑添加日志记录DBus调用的开始:
qDebug(logDBusHandler) << "Starting exportOpsLog D-Bus call with output directory:" << outDir;
  1. 考虑将超时时间设为可配置的,而不是硬编码:
// 在类中定义
const int DEFAULT_EXPORT_OPS_LOG_TIMEOUT_MS = 1200000;

// 在方法中使用
QDBusMessage reply = QDBusConnection::systemBus().call(message, QDBus::Block, m_exportOpsLogTimeoutMs);

这些改进可以提高代码的可维护性、可读性和健壮性,同时保持原有功能不变。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants