mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 17:07:52 +01:00
Fix upgrade failed after ever rollback (#1194)
* fix upgrade failed after rollback * fix upgrade failed after rollback * fix possible upgrade twice fail after rollback
This commit is contained in:
parent
f5476bdbb1
commit
74cde12677
@ -59,6 +59,12 @@ func addUnitsToTables(x *xorm.Engine) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var repoUnit RepoUnit
|
var repoUnit RepoUnit
|
||||||
|
if exist, err := sess.IsTableExist(&repoUnit); err != nil {
|
||||||
|
return fmt.Errorf("IsExist RepoUnit: %v", err)
|
||||||
|
} else if exist {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err := sess.CreateTable(&repoUnit); err != nil {
|
if err := sess.CreateTable(&repoUnit); err != nil {
|
||||||
return fmt.Errorf("CreateTable RepoUnit: %v", err)
|
return fmt.Errorf("CreateTable RepoUnit: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,14 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
|||||||
oldHookPath := filepath.Join(hookDir, hookName)
|
oldHookPath := filepath.Join(hookDir, hookName)
|
||||||
newHookPath := filepath.Join(hookDir, hookName+".d", "gitea")
|
newHookPath := filepath.Join(hookDir, hookName+".d", "gitea")
|
||||||
|
|
||||||
if err = os.MkdirAll(filepath.Join(hookDir, hookName+".d"), os.ModePerm); err != nil {
|
customHooksDir := filepath.Join(hookDir, hookName+".d")
|
||||||
return fmt.Errorf("create hooks dir '%s': %v", filepath.Join(hookDir, hookName+".d"), err)
|
// if it's exist, that means you have upgraded ever
|
||||||
|
if com.IsExist(customHooksDir) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = os.MkdirAll(customHooksDir, os.ModePerm); err != nil {
|
||||||
|
return fmt.Errorf("create hooks dir '%s': %v", customHooksDir, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARNING: Old server-side hooks will be moved to sub directory with the same name
|
// WARNING: Old server-side hooks will be moved to sub directory with the same name
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
@ -40,7 +41,8 @@ func useNewNameAvatars(x *xorm.Engine) error {
|
|||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
userID, err := strconv.ParseInt(name, 10, 64)
|
userID, err := strconv.ParseInt(name, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Warn("ignore avatar %s rename: %v", name, err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var user User
|
var user User
|
||||||
|
Loading…
Reference in New Issue
Block a user