From ff48aeddeff2e16f45fe4bae1220f3ed47b786a4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 25 May 2014 20:57:01 -0400 Subject: [PATCH] Little bug fix --- cmd/web.go | 14 ++++++++++++++ gogs.go | 12 ------------ modules/setting/setting.go | 2 +- routers/install.go | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cmd/web.go b/cmd/web.go index 2019b4405d..f4b31dcd5d 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -18,6 +18,7 @@ import ( "github.com/gogits/gogs/modules/auth/apiv1" "github.com/gogits/gogs/modules/avatar" "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/bin" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/middleware/binding" @@ -39,6 +40,18 @@ and it takes care of all the other things for you`, Flags: []cli.Flag{}, } +func checkVersion() { + // go-bindata -ignore=\\.DS_Store -o modules/bin/conf.go -pkg="bin" conf/... + // Check if binary and static file version match. + data, err := bin.Asset("conf/VERSION") + if err != nil { + log.Fatal("Fail to read 'conf/VERSION': %v", err) + } + if string(data) != setting.AppVer { + log.Fatal("Binary and static file version does not match, did you forget to recompile?") + } +} + func newMartini() *martini.ClassicMartini { r := martini.NewRouter() m := martini.New() @@ -52,6 +65,7 @@ func newMartini() *martini.ClassicMartini { } func runWeb(*cli.Context) { + checkVersion() routers.GlobalInit() m := newMartini() diff --git a/gogs.go b/gogs.go index ed6769348d..2d4af4eae7 100644 --- a/gogs.go +++ b/gogs.go @@ -14,8 +14,6 @@ import ( "github.com/codegangsta/cli" "github.com/gogits/gogs/cmd" - "github.com/gogits/gogs/modules/bin" - "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/setting" ) @@ -23,17 +21,7 @@ const APP_VER = "0.3.6.0525 Alpha" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) - - // go-bindata -ignore=\\.DS_Store -debug -o modules/bin/conf.go -pkg="bin" conf/... - // Set and check if binary and static file version match. setting.AppVer = APP_VER - data, err := bin.Asset("conf/VERSION") - if err != nil { - log.Fatal("Fail to read 'conf/VERSION': %v", err) - } - if string(data) != setting.AppVer { - log.Fatal("Binary and static file version does not match, did you forget to recompile?") - } } func main() { diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 451b2378e1..7ae31a22dc 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -99,6 +99,7 @@ func WorkDir() (string, error) { } // NewConfigContext initializes configuration context. +// NOTE: do not print any log except error. func NewConfigContext() { workDir, err := WorkDir() if err != nil { @@ -118,7 +119,6 @@ func NewConfigContext() { if len(CustomPath) == 0 { CustomPath = path.Join(workDir, "custom") } - log.Trace("Custom path: %s", CustomPath) cfgPath := path.Join(CustomPath, "conf/app.ini") if com.IsFile(cfgPath) { diff --git a/routers/install.go b/routers/install.go index f02c41f87e..f173563960 100644 --- a/routers/install.go +++ b/routers/install.go @@ -46,6 +46,7 @@ func NewServices() { // GlobalInit is for global configuration reload-able. func GlobalInit() { setting.NewConfigContext() + log.Trace("Custom path: %s", setting.CustomPath) mailer.NewMailerContext() models.LoadModelsConfig() models.LoadRepoConfig()