fix: Enhance the installation failure notification text#315
fix: Enhance the installation failure notification text#315qiuzhiqian merged 1 commit intomasterfrom
Conversation
|
CLA Assistant Lite bot: |
deepin pr auto review这份代码审查主要针对 1. 语法与逻辑审查
2. 代码质量审查
3. 代码性能审查
4. 代码安全审查
5. 改进建议代码示例针对代码重复问题,以下是一个重构建议: func (m *Manager) preFailedHook(job *Job, mode system.UpdateType, uuid string) error {
// ... 前面的代码 ...
// 定义常量和变量
const actionReboot = "reboot"
var (
msg string
action []string
hints map[string]dbus.Variant
)
// 辅助函数:设置已备份状态的通知参数
setupBackedUpParams := func() {
action = []string{actionReboot, gettext.Tr("Reboot")}
hints = map[string]dbus.Variant{
"x-deepin-action-" + actionReboot: dbus.MakeVariant("dbus-send,--session,--print-reply,--dest=org.deepin.dde.ShutdownFront1,/org/deepin/dde/ShutdownFront1,org.deepin.dde.ShutdownFront1.Restart"),
"x-deepin-NoAnimationActions": dbus.MakeVariant(actionReboot),
}
}
// 辅助函数:设置未备份状态的通知参数
setupNotBackedUpParams := func() {
action = []string{}
hints = nil
}
// 根据错误类型和备份状态设置参数
if strings.Contains(errType, system.ErrorInsufficientSpace.String()) {
if m.statusManager.abStatus == system.HasBackedUp {
msg = gettext.Tr("Updates failed: insufficient disk space. Please reboot to avoid the effect on your system.")
setupBackedUpParams()
} else {
msg = gettext.Tr("Updates failed: insufficient disk space.")
setupNotBackedUpParams()
}
} else {
// 其他错误
if m.statusManager.abStatus == system.HasBackedUp {
msg = gettext.Tr("Updates failed. Please reboot to avoid the effect on your system.")
setupBackedUpParams()
} else {
msg = gettext.Tr("Updates failed.")
setupNotBackedUpParams()
}
}
// 发送通知
timeout := system.NotifyExpireTimeoutDefault
if m.config.IntranetUpdate {
timeout = system.NotifyExpireTimeoutPrivateLong
}
go m.sendNotify(updateNotifyShowOptional, 0, "preferences-system", "", msg, action, hints, timeout)
// ... 后面的代码 ...
}总结这次修改主要目的是在更新失败且系统已备份的情况下,引导用户重启以恢复系统。逻辑上是正确的,但代码实现上存在较多重复。建议进行适当重构以提高可读性和可维护性。同时,本地化文件的更新与代码逻辑保持一致。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: qiuzhiqian, zhaohuiw42 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
No description provided.