0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-30 07:16:19 +01:00

Merge pull request #866 from vitalvas/dev

Fix in url if cache avatar is enabled
This commit is contained in:
无闻 2015-01-20 13:38:17 +08:00
commit 830bc75107

View File

@ -38,10 +38,12 @@ import (
var gravatarSource string
func init() {
func UpdateGravatarSource() {
gravatarSource = setting.GravatarSource
log.Debug("avatar.UpdateGravatarSource(gavatar source): %s", gravatarSource)
if !strings.HasPrefix(gravatarSource, "http:") {
gravatarSource = "http:" + gravatarSource
log.Debug("avatar.UpdateGravatarSource(update gavatar source): %s", gravatarSource)
}
}
@ -131,11 +133,13 @@ func (this *Avatar) Encode(wr io.Writer, size int) (err error) {
// get image from gravatar.com
func (this *Avatar) Update() {
UpdateGravatarSource()
thunder.Fetch(gravatarSource+this.Hash+"?"+this.reqParams,
this.imagePath)
}
func (this *Avatar) UpdateTimeout(timeout time.Duration) (err error) {
UpdateGravatarSource()
select {
case <-time.After(timeout):
err = fmt.Errorf("get gravatar image %s timeout", this.Hash)