diff --git a/backend/app/service/backup_app.go b/backend/app/service/backup_app.go index ec00836d3..412d8f3fb 100644 --- a/backend/app/service/backup_app.go +++ b/backend/app/service/backup_app.go @@ -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 { global.LOG.Errorf("handle recover from app.tar.gz failed, err: %v", err) + _ = fileOp.DeleteDir(appDir) + _ = fileOp.Rename(backPath, appDir) return err } + _ = fileOp.DeleteDir(backPath) if len(newEnvFile) != 0 { 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 } isOk = true + return nil } diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 767c94004..0e7e2d665 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -124,7 +124,7 @@ const checkSimpleName = (rule: any, value: any, callback: any) => { if (value === '' || typeof value === 'undefined' || value == null) { callback(new Error(i18n.global.t('commons.rule.simpleName'))); } 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 !== '') { callback(new Error(i18n.global.t('commons.rule.simpleName'))); } else {