mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-18 22:22:59 +08:00
feat: 修改同步应用备份逻辑
This commit is contained in:
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…
Reference in New Issue
Block a user