From 895dde74ddbcd0c301eff555ecb2fce73eadd475 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:42:05 +0800 Subject: [PATCH] fix: Fix local application backup failure in snapshots (#11341) --- agent/app/dto/snapshot.go | 1 + agent/app/service/snapshot.go | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/agent/app/dto/snapshot.go b/agent/app/dto/snapshot.go index 9a12b0935..dd962c89a 100644 --- a/agent/app/dto/snapshot.go +++ b/agent/app/dto/snapshot.go @@ -52,6 +52,7 @@ type DataTree struct { Label string `json:"label"` Key string `json:"key"` Name string `json:"name"` + IsLocal bool `json:"isLocal"` Size uint64 `json:"size"` IsCheck bool `json:"isCheck"` IsDisable bool `json:"isDisable"` diff --git a/agent/app/service/snapshot.go b/agent/app/service/snapshot.go index af952a4e8..3392e2e7c 100644 --- a/agent/app/service/snapshot.go +++ b/agent/app/service/snapshot.go @@ -224,12 +224,16 @@ func loadApps(fileOp fileUtils.FileOp) ([]dto.DataTree, error) { appTreeMap := make(map[string]dto.DataTree) for _, app := range apps { itemApp := dto.DataTree{ - ID: uuid.NewString(), - Label: fmt.Sprintf("%s - %s", app.App.Name, app.Name), - Key: app.App.Key, - Name: app.Name, + ID: uuid.NewString(), + Label: fmt.Sprintf("%s - %s", app.App.Name, app.Name), + Key: app.App.Key, + Name: app.Name, + IsLocal: app.App.Resource == "local", } appPath := path.Join(global.Dir.DataDir, "apps", app.App.Key, app.Name) + if itemApp.IsLocal { + appPath = path.Join(global.Dir.AppDir, "local", strings.TrimPrefix(app.App.Key, "local"), app.Name) + } itemAppData := dto.DataTree{ID: uuid.NewString(), Label: "appData", Key: app.App.Key, Name: app.Name, IsCheck: true, Path: appPath} if app.App.Key == constant.AppOpenresty && len(websites) != 0 { itemAppData.IsDisable = true @@ -295,7 +299,7 @@ func loadAppImage(list []dto.DataTree) []dto.DataTree { for i := 0; i < len(list); i++ { itemAppImage := dto.DataTree{ID: uuid.NewString(), Label: "appImage"} - stdout, err := cmd.RunDefaultWithStdoutBashCf("cat %s | grep image: ", path.Join(global.Dir.AppDir, list[i].Key, list[i].Name, "docker-compose.yml")) + stdout, err := cmd.RunDefaultWithStdoutBashCf("cat %s | grep image: ", list[i].Path) if err != nil { list[i].Children = append(list[i].Children, itemAppImage) continue