From 0806725ca51770abf12fa3b5e99542826c123c77 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 6 Sep 2015 18:19:30 -0400 Subject: [PATCH] minor fix on #1589 Signed-off-by: Unknwon --- models/repo.go | 8 ++++++-- models/user.go | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/models/repo.go b/models/repo.go index 06c97baf..62a8b974 100644 --- a/models/repo.go +++ b/models/repo.go @@ -472,8 +472,12 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str // Check if repository is empty. _, stderr, err = com.ExecCmdDir(repoPath, "git", "log", "-1") - if err != nil && strings.Contains(stderr, "fatal: bad default revision 'HEAD'") { - repo.IsBare = true + if err != nil { + if strings.Contains(stderr, "fatal: bad default revision 'HEAD'") { + repo.IsBare = true + } else { + return repo, fmt.Errorf("check bare: %v - %s", err, stderr) + } } // Check if repository has master branch, if so set it to default branch. diff --git a/models/user.go b/models/user.go index fdd9429a..641e14d0 100644 --- a/models/user.go +++ b/models/user.go @@ -231,28 +231,27 @@ func (u *User) UploadAvatar(data []byte) error { if err != nil { return err } + m := resize.Resize(234, 234, img, resize.NearestNeighbor) sess := x.NewSession() - defer sess.Close() + defer sessionRelease(sess) if err = sess.Begin(); err != nil { return err } if _, err = sess.Id(u.Id).AllCols().Update(u); err != nil { - sess.Rollback() return err } os.MkdirAll(setting.AvatarUploadPath, os.ModePerm) fw, err := os.Create(u.CustomAvatarPath()) if err != nil { - sess.Rollback() return err } defer fw.Close() + if err = jpeg.Encode(fw, m, nil); err != nil { - sess.Rollback() return err }