Skip to content

Commit 895dde7

Browse files
authored
fix: Fix local application backup failure in snapshots (#11341)
1 parent c477d20 commit 895dde7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

agent/app/dto/snapshot.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type DataTree struct {
5252
Label string `json:"label"`
5353
Key string `json:"key"`
5454
Name string `json:"name"`
55+
IsLocal bool `json:"isLocal"`
5556
Size uint64 `json:"size"`
5657
IsCheck bool `json:"isCheck"`
5758
IsDisable bool `json:"isDisable"`

agent/app/service/snapshot.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,16 @@ func loadApps(fileOp fileUtils.FileOp) ([]dto.DataTree, error) {
224224
appTreeMap := make(map[string]dto.DataTree)
225225
for _, app := range apps {
226226
itemApp := dto.DataTree{
227-
ID: uuid.NewString(),
228-
Label: fmt.Sprintf("%s - %s", app.App.Name, app.Name),
229-
Key: app.App.Key,
230-
Name: app.Name,
227+
ID: uuid.NewString(),
228+
Label: fmt.Sprintf("%s - %s", app.App.Name, app.Name),
229+
Key: app.App.Key,
230+
Name: app.Name,
231+
IsLocal: app.App.Resource == "local",
231232
}
232233
appPath := path.Join(global.Dir.DataDir, "apps", app.App.Key, app.Name)
234+
if itemApp.IsLocal {
235+
appPath = path.Join(global.Dir.AppDir, "local", strings.TrimPrefix(app.App.Key, "local"), app.Name)
236+
}
233237
itemAppData := dto.DataTree{ID: uuid.NewString(), Label: "appData", Key: app.App.Key, Name: app.Name, IsCheck: true, Path: appPath}
234238
if app.App.Key == constant.AppOpenresty && len(websites) != 0 {
235239
itemAppData.IsDisable = true
@@ -295,7 +299,7 @@ func loadAppImage(list []dto.DataTree) []dto.DataTree {
295299

296300
for i := 0; i < len(list); i++ {
297301
itemAppImage := dto.DataTree{ID: uuid.NewString(), Label: "appImage"}
298-
stdout, err := cmd.RunDefaultWithStdoutBashCf("cat %s | grep image: ", path.Join(global.Dir.AppDir, list[i].Key, list[i].Name, "docker-compose.yml"))
302+
stdout, err := cmd.RunDefaultWithStdoutBashCf("cat %s | grep image: ", list[i].Path)
299303
if err != nil {
300304
list[i].Children = append(list[i].Children, itemAppImage)
301305
continue

0 commit comments

Comments
 (0)