Signed-off-by: Unknwon <u@gogs.io>
tokarchuk/v1.17
Unknwon 9 years ago
parent d504ee0417
commit 0806725ca5
  1. 6
      models/repo.go
  2. 7
      models/user.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'") {
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.

@ -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
}

Loading…
Cancel
Save