fix: 解决 Mysql 恢复失败的问题 (#1874)

pull/1882/head
zhengkunwang 1 year ago committed by GitHub
parent 381233a8a5
commit ce258cf157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -208,10 +208,18 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback
} }
} }
appDir := install.GetPath()
backPath := fmt.Sprintf("%s_bak", appDir)
_ = fileOp.Rename(appDir, backPath)
_ = fileOp.CreateDir(appDir, 0755)
if err := handleUnTar(tmpPath+"/app.tar.gz", fmt.Sprintf("%s/%s", constant.AppInstallDir, install.App.Key)); err != nil { if err := handleUnTar(tmpPath+"/app.tar.gz", fmt.Sprintf("%s/%s", constant.AppInstallDir, install.App.Key)); err != nil {
global.LOG.Errorf("handle recover from app.tar.gz failed, err: %v", err) global.LOG.Errorf("handle recover from app.tar.gz failed, err: %v", err)
_ = fileOp.DeleteDir(appDir)
_ = fileOp.Rename(backPath, appDir)
return err return err
} }
_ = fileOp.DeleteDir(backPath)
if len(newEnvFile) != 0 { if len(newEnvFile) != 0 {
envPath := fmt.Sprintf("%s/%s/%s/.env", constant.AppInstallDir, install.App.Key, install.Name) envPath := fmt.Sprintf("%s/%s/%s/.env", constant.AppInstallDir, install.App.Key, install.Name)
@ -233,6 +241,7 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback
return err return err
} }
isOk = true isOk = true
return nil return nil
} }

@ -124,7 +124,7 @@ const checkSimpleName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) { if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.simpleName'))); callback(new Error(i18n.global.t('commons.rule.simpleName')));
} else { } else {
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{0,30}$/; const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{1,29}$/;
if (!reg.test(value) && value !== '') { if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.simpleName'))); callback(new Error(i18n.global.t('commons.rule.simpleName')));
} else { } else {

Loading…
Cancel
Save