Skip to content

Commit 51279ac

Browse files
committed
fix: Solve the issue where "lastore-apt-clean" outputs warning messages
Description: A file is detected missing during the initialization of the config Log: Use the dde-dconfig command to retrieve configuration values Bug: https://pms.uniontech.com/bug-view-338213.html Influence: Command output
1 parent 11664fe commit 51279ac

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/lastore-apt-clean/main.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ import (
1414
"io"
1515
"os"
1616
"os/exec"
17-
"path"
1817
"path/filepath"
18+
"strings"
1919
"syscall"
2020
"time"
2121

22-
. "github.com/linuxdeepin/lastore-daemon/src/internal/config"
2322
"github.com/linuxdeepin/lastore-daemon/src/internal/system"
2423

2524
"github.com/linuxdeepin/go-lib/log"
@@ -75,11 +74,17 @@ func main() {
7574
findBins()
7675

7776
// 如果是增量更新,则调用deepin-immutable-ctl upgrade cleanup命令清理immutable系统的缓存deb包和ostree包分支
78-
config := NewConfig(path.Join("/var/lib/lastore", "config.json"))
79-
if config.IncrementalUpdate {
80-
cmd := exec.Command("deepin-immutable-ctl", "upgrade", "clean")
81-
if err := cmd.Run(); err != nil {
82-
logger.Warningf("failed to clean upgrade cache: %v", err)
77+
IncrementalUpdate, err := exec.Command("dde-dconfig", "get", "-a", "org.deepin.dde.lastore", "-r", "org.deepin.dde.lastore", "-k", "incremental-update").Output()
78+
if err != nil {
79+
logger.Debugf("dde-dconfig get -a \"org.deepin.dde.lastore\" -r \"org.deepin.dde.lastore\" -k incremental-update failed:%v\n", err)
80+
} else {
81+
IncrementalUpdateStr := strings.TrimSpace(string(IncrementalUpdate))
82+
isIncrementalUpdate := strings.EqualFold(string(IncrementalUpdateStr), "true")
83+
if isIncrementalUpdate {
84+
err := exec.Command("deepin-immutable-ctl", "upgrade", "clean").Run()
85+
if err != nil {
86+
logger.Debugf("failed to clean upgrade cache: %v", err)
87+
}
8388
}
8489
}
8590

0 commit comments

Comments
 (0)