feat: 修改同步应用备份逻辑

pull/73/head
zhengkunwang223 2 years ago committed by zhengkunwang223
parent cb3b01cfe9
commit 6260281cac

@ -570,7 +570,8 @@ func getAppFromOss() error {
}
fileOp := files.NewFileOp()
if _, err := fileOp.Backup(appDir); err != nil {
if _, err := fileOp.CopyAndBackup(appDir); err != nil {
return err
}

@ -433,5 +433,23 @@ func (f FileOp) Backup(srcFile string) (string, error) {
if err := f.Rename(srcFile, backupPath); err != nil {
return backupPath, err
}
return backupPath, nil
}
func (f FileOp) CopyAndBackup(src string) (string, error) {
backupPath := src + "_bak"
info, _ := f.Fs.Stat(backupPath)
if info != nil {
if info.IsDir() {
_ = f.DeleteDir(backupPath)
} else {
_ = f.DeleteFile(backupPath)
}
}
_ = f.CreateDir(backupPath, 0755)
if err := f.Copy(src, backupPath); err != nil {
return backupPath, err
}
return backupPath, nil
}

Loading…
Cancel
Save