Skip to content

Commit 6a0f921

Browse files
Fire-dtxqiuzhiqian
authored andcommitted
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 73e92ac commit 6a0f921

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/lastore-apt-clean/main.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ import (
1414
"io"
1515
"os"
1616
"os/exec"
17-
"path"
1817
"path/filepath"
1918
"syscall"
2019
"time"
2120

22-
. "github.com/linuxdeepin/lastore-daemon/src/internal/config"
2321
"github.com/linuxdeepin/lastore-daemon/src/internal/system"
2422

2523
"github.com/linuxdeepin/go-lib/log"
@@ -48,12 +46,14 @@ func mustGetBin(name string) string {
4846
var options struct {
4947
forceDelete bool
5048
printJSON bool
49+
incrementalUpdate bool
5150
}
5251

5352
func init() {
5453
flag.BoolVar(&options.forceDelete, "force-delete", false, "force delete deb files")
5554
flag.BoolVar(&options.printJSON, "print-json", false,
5655
"Print information about files that can be safely deleted, in json format")
56+
flag.BoolVar(&options.incrementalUpdate, "incremental-update", false, "whether to enable incremental update")
5757
_ = os.Setenv("LC_ALL", "C")
5858
}
5959

@@ -75,11 +75,10 @@ func main() {
7575
findBins()
7676

7777
// 如果是增量更新,则调用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)
78+
if options.incrementalUpdate {
79+
err := exec.Command("deepin-immutable-ctl", "upgrade", "clean").Run()
80+
if err != nil {
81+
logger.Debugf("failed to clean upgrade cache: %v", err)
8382
}
8483
}
8584

src/lastore-daemon/common.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/linuxdeepin/lastore-daemon/src/internal/system"
3030
"github.com/linuxdeepin/lastore-daemon/src/internal/system/apt"
3131
"github.com/linuxdeepin/lastore-daemon/src/internal/utils"
32+
. "github.com/linuxdeepin/lastore-daemon/src/internal/config"
3233

3334
"github.com/godbus/dbus/v5"
3435
"github.com/linuxdeepin/go-lib/dbusutil"
@@ -193,15 +194,25 @@ func listPackageDesktopFiles(pkg string) []string {
193194
}
194195

195196
func getArchiveInfo() (string, error) {
196-
out, err := exec.Command("/usr/bin/lastore-apt-clean", "-print-json").Output()
197+
config := NewConfig(path.Join("/var/lib/lastore", "config.json"))
198+
isIncrementalUpdate := ""
199+
if config.IncrementalUpdate {
200+
isIncrementalUpdate = "--incremental-update"
201+
}
202+
out, err := exec.Command("/usr/bin/lastore-apt-clean", "-print-json", isIncrementalUpdate).Output()
197203
if err != nil {
198204
return "", err
199205
}
200206
return string(out), nil
201207
}
202208

203209
func getNeedCleanCacheSize() (float64, error) {
204-
output, err := exec.Command("/usr/bin/lastore-apt-clean", "-print-json").Output()
210+
config := NewConfig(path.Join("/var/lib/lastore", "config.json"))
211+
isIncrementalUpdate := ""
212+
if config.IncrementalUpdate {
213+
isIncrementalUpdate = "--incremental-update"
214+
}
215+
output, err := exec.Command("/usr/bin/lastore-apt-clean", "-print-json", isIncrementalUpdate).Output()
205216
if err != nil {
206217
return 0, err
207218
}

0 commit comments

Comments
 (0)