mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
[FIX] fix restore bug
This commit is contained in:
parent
4097ff78c2
commit
f8f28eec51
@ -522,7 +522,7 @@ func (b *BackupAPPRestore) downloadFromLocal(backup *dbmodel.AppBackup) error {
|
|||||||
logrus.Errorf("unzip file error when restore backup app , %s", err.Error())
|
logrus.Errorf("unzip file error when restore backup app , %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dirs, err := util.GetDirList(b.cacheDir, 1)
|
dirs, err := util.GetDirNameList(b.cacheDir, 1)
|
||||||
if err != nil || len(dirs) < 1 {
|
if err != nil || len(dirs) < 1 {
|
||||||
b.Logger.Error(util.Translation("unzip metadata file error"), map[string]string{"step": "backup_builder", "status": "failure"})
|
b.Logger.Error(util.Translation("unzip metadata file error"), map[string]string{"step": "backup_builder", "status": "failure"})
|
||||||
return fmt.Errorf("find metadata cache dir error after unzip file")
|
return fmt.Errorf("find metadata cache dir error after unzip file")
|
||||||
@ -551,7 +551,7 @@ func (b *BackupAPPRestore) downloadFromFTP(backup *dbmodel.AppBackup) error {
|
|||||||
logrus.Errorf("unzip file error when restore backup app , %s", err.Error())
|
logrus.Errorf("unzip file error when restore backup app , %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dirs, err := util.GetDirList(b.cacheDir, 1)
|
dirs, err := util.GetDirNameList(b.cacheDir, 1)
|
||||||
if err != nil || len(dirs) < 1 {
|
if err != nil || len(dirs) < 1 {
|
||||||
b.Logger.Error(util.Translation("unzip metadata file error"), map[string]string{"step": "backup_builder", "status": "failure"})
|
b.Logger.Error(util.Translation("unzip metadata file error"), map[string]string{"step": "backup_builder", "status": "failure"})
|
||||||
return fmt.Errorf("find metadata cache dir error after unzip file")
|
return fmt.Errorf("find metadata cache dir error after unzip file")
|
||||||
|
@ -542,3 +542,26 @@ func GetDirList(dirpath string, level int) ([]string, error) {
|
|||||||
}
|
}
|
||||||
return dirlist, nil
|
return dirlist, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDirNameList get all lower level dir
|
||||||
|
func GetDirNameList(dirpath string, level int) ([]string, error) {
|
||||||
|
var dirlist []string
|
||||||
|
list, err := ioutil.ReadDir(dirpath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, f := range list {
|
||||||
|
if f.IsDir() {
|
||||||
|
if level <= 1 {
|
||||||
|
dirlist = append(dirlist, f.Name())
|
||||||
|
} else {
|
||||||
|
list, err := GetDirList(filepath.Join(dirpath, f.Name()), level-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dirlist = append(dirlist, list...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dirlist, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user