fix: initialize lastore config to clean incremental update cache#324
fix: initialize lastore config to clean incremental update cache#324zhaohuiw42 merged 1 commit intolinuxdeepin:masterfrom
Conversation
|
CLA Assistant Lite bot: |
lastore-apt-clean did not initialize lastore config before running, so incremental update settings were not applied correctly and incremental update cache could not be cleaned. Task: https://pms.uniontech.com/task-view-386845.html
deepin pr auto review代码审查报告总体评价这段代码主要进行了以下改动:
整体来看,代码逻辑清晰,但存在一些可以改进的地方。 详细审查意见1. 语法逻辑问题config.go
lastore-apt-clean/main.go
lastore-daemon/common.go
2. 代码质量建议config.go// DisableConsoleLogging keeps config logs away from stdout for commands that
// need machine-readable output.
func DisableConsoleLogging() {
logger.RemoveBackendConsole()
}建议添加注释说明这个函数是线程安全的,或者确保其实现是线程安全的。 lastore-apt-clean/main.gocfg := config.NewConfig(path.Join("/var/lib/lastore", "config.json"))
if cfg.IncrementalUpdate {
err := exec.Command("deepin-immutable-ctl", "upgrade", "clean").Run()
if err != nil {
logger.Debugf("failed to clean upgrade cache: %v", err)
}
}建议:
改进建议: const (
configDir = "/var/lib/lastore"
configFile = "config.json"
)
// 在main函数中
configPath := filepath.Join(configDir, configFile)
cfg, err := config.NewConfig(configPath)
if err != nil {
logger.Warningf("Failed to load config from %s: %v", configPath, err)
// 根据业务逻辑决定是否继续执行
}lastore-daemon/common.gofunc getArchiveInfo() (string, error) {
out, err := exec.Command("/usr/bin/lastore-apt-clean", "-print-json").Output()
if err != nil {
return "", err
}
return string(out), nil
}建议:
改进建议: const (
lastoreAptCleanCmd = "/usr/bin/lastore-apt-clean"
)
func getArchiveInfo() (string, error) {
cmd := exec.Command(lastoreAptCleanCmd, "-print-json")
// 设置超时
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
out, err := cmd.CombinedOutput()
if err != nil {
logger.Warningf("Failed to get archive info: %v, output: %s", err, string(out))
return "", err
}
return string(out), nil
}3. 代码性能建议
4. 代码安全建议
总结这段代码整体质量良好,主要改进点在于:
建议在合并前进行充分的测试,特别是与增量更新相关的功能。 |
|
[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 |
lastore-apt-clean did not initialize lastore config before running, so incremental update settings were not applied correctly and incremental update cache could not be cleaned.
Task: https://pms.uniontech.com/task-view-386845.html