Fix bug work with sqlite3
This commit is contained in:
parent
d0e6a4c25a
commit
2a0066420a
8 changed files with 31 additions and 12 deletions
|
@ -26,6 +26,8 @@ type Access struct {
|
|||
|
||||
// AddAccess adds new access record.
|
||||
func AddAccess(access *Access) error {
|
||||
access.UserName = strings.ToLower(access.UserName)
|
||||
access.RepoName = strings.ToLower(access.RepoName)
|
||||
_, err := orm.Insert(access)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/lunny/xorm"
|
||||
// _ "github.com/mattn/go-sqlite3"
|
||||
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
)
|
||||
|
@ -23,10 +24,15 @@ var (
|
|||
DbCfg struct {
|
||||
Type, Host, Name, User, Pwd, Path, SslMode string
|
||||
}
|
||||
|
||||
UseSQLite3 bool
|
||||
)
|
||||
|
||||
func LoadModelsConfig() {
|
||||
DbCfg.Type = base.Cfg.MustValue("database", "DB_TYPE")
|
||||
if DbCfg.Type == "sqlite3" {
|
||||
UseSQLite3 = true
|
||||
}
|
||||
DbCfg.Host = base.Cfg.MustValue("database", "HOST")
|
||||
DbCfg.Name = base.Cfg.MustValue("database", "NAME")
|
||||
DbCfg.User = base.Cfg.MustValue("database", "USER")
|
||||
|
|
|
@ -157,7 +157,7 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
|
|||
}
|
||||
|
||||
access := Access{
|
||||
UserName: user.Name,
|
||||
UserName: user.LowerName,
|
||||
RepoName: strings.ToLower(path.Join(user.Name, repo.Name)),
|
||||
Mode: AU_WRITABLE,
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ var (
|
|||
ErrUserNotExist = errors.New("User does not exist")
|
||||
ErrEmailAlreadyUsed = errors.New("E-mail already used")
|
||||
ErrUserNameIllegal = errors.New("User name contains illegal characters")
|
||||
ErrKeyNotExist = errors.New("Public key does not exist")
|
||||
)
|
||||
|
||||
// User represents the object of individual and member of organization.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue