Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat(upgrade): replace i18n bundle using the upgrade command

LinkinStarsea54aa75dba4
diff --git a/cmd/command.go b/cmd/command.go
index bfcb1414..67f9ce34 100644
--- a/cmd/command.go
+++ b/cmd/command.go
@@ -101,6 +101,7 @@ To run answer, use:
Long: `upgrade Answer version`,
Run: func(_ *cobra.Command, _ []string) {
cli.FormatAllPath(dataDirPath)
+ cli.InstallI18nBundle(true)
c, err := conf.ReadConfig(cli.GetConfigFilePath())
if err != nil {
fmt.Println("read config failed: ", err.Error())
diff --git a/internal/cli/install.go b/internal/cli/install.go
index e2d278f1..5fb4fe1f 100644
--- a/internal/cli/install.go
+++ b/internal/cli/install.go
@@ -40,7 +40,7 @@ func FormatAllPath(dataDirPath string) {
func InstallAllInitialEnvironment(dataDirPath string) {
FormatAllPath(dataDirPath)
installUploadDir()
- installI18nBundle()
+ InstallI18nBundle(false)
fmt.Println("install all initial environment done")
}
@@ -79,7 +79,7 @@ func installUploadDir() {
}
}
-func installI18nBundle() {
+func InstallI18nBundle(replace bool) {
fmt.Println("[i18n] try to install i18n bundle...")
if err := dir.CreateDirIfNotExist(I18nPath); err != nil {
fmt.Println(err.Error())
@@ -98,7 +98,11 @@ func installI18nBundle() {
if err != nil {
continue
}
- if dir.CheckFileExist(path) {
+ exist := dir.CheckFileExist(path)
+ if exist && !replace {
+ continue
+ }
+ if exist {
fmt.Printf("[i18n] install %s file exist, try to replace it\n", item.Name())
if err = os.Remove(path); err != nil {
fmt.Println(err)