summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-06 18:19:30 -0400
committerUnknwon <u@gogs.io>2015-09-06 18:19:30 -0400
commit0806725ca51770abf12fa3b5e99542826c123c77 (patch)
treecbb4df8e0542325fb330eaf934b9a080e18a1f64
parentd504ee04170551f9140526379963a35fb73298aa (diff)
downloadgitea-0806725ca51770abf12fa3b5e99542826c123c77.tar.gz
gitea-0806725ca51770abf12fa3b5e99542826c123c77.zip
minor fix on #1589
Signed-off-by: Unknwon <u@gogs.io>
-rw-r--r--models/repo.go8
-rw-r--r--models/user.go7
2 files changed, 9 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go
index 06c97baf24..62a8b9740d 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 fdd9429aa3..641e14d0ce 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
}