fix: Fix local application backup failure in snapshots (#11341)

This commit is contained in:
ssongliu 2025-12-15 18:42:05 +08:00 committed by GitHub
parent c477d20a05
commit 895dde74dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View file

@ -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"`

View file

@ -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