PLT-3456 Fix Errors while starting the server (#3445)
* PLT-3456 AppErrors that are triggered before translations are loaded crash server or produce bad error messages. * Fixing tests
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
5dfa4fb629
Коммит
2305b2597f
@@ -29,6 +29,7 @@ type TestHelper struct {
|
|||||||
|
|
||||||
func SetupEnterprise() *TestHelper {
|
func SetupEnterprise() *TestHelper {
|
||||||
if Srv == nil {
|
if Srv == nil {
|
||||||
|
utils.TranslationsPreInit()
|
||||||
utils.LoadConfig("config.json")
|
utils.LoadConfig("config.json")
|
||||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||||
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
||||||
@@ -49,6 +50,7 @@ func SetupEnterprise() *TestHelper {
|
|||||||
|
|
||||||
func Setup() *TestHelper {
|
func Setup() *TestHelper {
|
||||||
if Srv == nil {
|
if Srv == nil {
|
||||||
|
utils.TranslationsPreInit()
|
||||||
utils.LoadConfig("config.json")
|
utils.LoadConfig("config.json")
|
||||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||||
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
||||||
|
|||||||
@@ -74,12 +74,12 @@ func doLoadConfig(filename string) (err string) {
|
|||||||
err = fmt.Sprintf("%v", r)
|
err = fmt.Sprintf("%v", r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
utils.TranslationsPreInit()
|
||||||
utils.LoadConfig(filename)
|
utils.LoadConfig(filename)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
parseCmds()
|
parseCmds()
|
||||||
|
|
||||||
if errstr := doLoadConfig(flagConfigFile); errstr != "" {
|
if errstr := doLoadConfig(flagConfigFile); errstr != "" {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var store Store
|
|||||||
|
|
||||||
func Setup() {
|
func Setup() {
|
||||||
if store == nil {
|
if store == nil {
|
||||||
|
utils.TranslationsPreInit()
|
||||||
utils.LoadConfig("config.json")
|
utils.LoadConfig("config.json")
|
||||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||||
store = NewSqlStore()
|
store = NewSqlStore()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestConfig(t *testing.T) {
|
func TestConfig(t *testing.T) {
|
||||||
|
TranslationsPreInit()
|
||||||
LoadConfig("config.json")
|
LoadConfig("config.json")
|
||||||
InitTranslations(Cfg.LocalizationSettings)
|
InitTranslations(Cfg.LocalizationSettings)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,16 @@ var T i18n.TranslateFunc
|
|||||||
var locales map[string]string = make(map[string]string)
|
var locales map[string]string = make(map[string]string)
|
||||||
var settings model.LocalizationSettings
|
var settings model.LocalizationSettings
|
||||||
|
|
||||||
|
// this functions loads translations from filesystem
|
||||||
|
// and assign english while loading server config
|
||||||
|
func TranslationsPreInit() {
|
||||||
|
InitTranslationsWithDir("i18n")
|
||||||
|
T = TfuncWithFallback("en")
|
||||||
|
}
|
||||||
|
|
||||||
func InitTranslations(localizationSettings model.LocalizationSettings) {
|
func InitTranslations(localizationSettings model.LocalizationSettings) {
|
||||||
settings = localizationSettings
|
settings = localizationSettings
|
||||||
InitTranslationsWithDir("i18n")
|
T = GetTranslationsBySystemLocale()
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitTranslationsWithDir(dir string) {
|
func InitTranslationsWithDir(dir string) {
|
||||||
@@ -30,8 +37,6 @@ func InitTranslationsWithDir(dir string) {
|
|||||||
i18n.MustLoadTranslationFile(i18nDirectory + filename)
|
i18n.MustLoadTranslationFile(i18nDirectory + filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T = GetTranslationsBySystemLocale()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTranslationsBySystemLocale() i18n.TranslateFunc {
|
func GetTranslationsBySystemLocale() i18n.TranslateFunc {
|
||||||
|
|||||||
@@ -79,14 +79,14 @@ func TestConnection(config *model.Config) {
|
|||||||
|
|
||||||
conn, err1 := connectToSMTPServer(config)
|
conn, err1 := connectToSMTPServer(config)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
l4g.Error(T("utils.mail.test.configured.error"), err1.Message, err1.DetailedError)
|
l4g.Error(T("utils.mail.test.configured.error"), T(err1.Message), err1.DetailedError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
c, err2 := newSMTPClient(conn, config)
|
c, err2 := newSMTPClient(conn, config)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
l4g.Error(T("utils.mail.test.configured.error"), err2.Message, err2.DetailedError)
|
l4g.Error(T("utils.mail.test.configured.error"), T(err2.Message), err2.DetailedError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer c.Quit()
|
defer c.Quit()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ var URL string
|
|||||||
|
|
||||||
func Setup() {
|
func Setup() {
|
||||||
if api.Srv == nil {
|
if api.Srv == nil {
|
||||||
|
utils.TranslationsPreInit()
|
||||||
utils.LoadConfig("config.json")
|
utils.LoadConfig("config.json")
|
||||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||||
api.NewServer()
|
api.NewServer()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user