Browse Source

Check unhandled errors (#128)

for-closed-social
Matthias Loibl 8 years ago
committed by Andrey Nering
parent
commit
31da225309
2 changed files with 16 additions and 4 deletions
  1. +2
    -1
      main.go
  2. +14
    -3
      routers/install.go

+ 2
- 1
main.go View File

@ -8,6 +8,7 @@
package main
import (
"log"
"os"
"runtime"
@ -38,5 +39,5 @@ func main() {
cmd.CmdAdmin,
}
app.Flags = append(app.Flags, []cli.Flag{}...)
app.Run(os.Args)
log.Fatal(app.Run(os.Args))
}

+ 14
- 3
routers/install.go View File

@ -345,7 +345,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15))
os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
err := os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
if err != nil {
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
return
}
if err := cfg.SaveTo(setting.CustomConf); err != nil {
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
return
@ -375,8 +380,14 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
}
// Auto-login for admin
ctx.Session.Set("uid", u.ID)
ctx.Session.Set("uname", u.Name)
if err := ctx.Session.Set("uid", u.ID); err != nil {
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
return
}
if err := ctx.Session.Set("uname", u.Name); err != nil {
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
return
}
}
log.Info("First-time run install finished!")

Loading…
Cancel
Save