mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 16:44:26 +00:00
fix if service.ENABLE_CACHE_AVATAR is true
This commit is contained in:
parent
0e286a0ca9
commit
cf59057ef3
@ -38,10 +38,12 @@ import (
|
|||||||
|
|
||||||
var gravatarSource string
|
var gravatarSource string
|
||||||
|
|
||||||
func init() {
|
func UpdateGravatarSource() {
|
||||||
gravatarSource = setting.GravatarSource
|
gravatarSource = setting.GravatarSource
|
||||||
|
log.Debug("avatar.UpdateGravatarSource(gavatar source): %s", gravatarSource)
|
||||||
if !strings.HasPrefix(gravatarSource, "http:") {
|
if !strings.HasPrefix(gravatarSource, "http:") {
|
||||||
gravatarSource = "http:" + gravatarSource
|
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
|
// get image from gravatar.com
|
||||||
func (this *Avatar) Update() {
|
func (this *Avatar) Update() {
|
||||||
|
UpdateGravatarSource()
|
||||||
thunder.Fetch(gravatarSource+this.Hash+"?"+this.reqParams,
|
thunder.Fetch(gravatarSource+this.Hash+"?"+this.reqParams,
|
||||||
this.imagePath)
|
this.imagePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Avatar) UpdateTimeout(timeout time.Duration) (err error) {
|
func (this *Avatar) UpdateTimeout(timeout time.Duration) (err error) {
|
||||||
|
UpdateGravatarSource()
|
||||||
select {
|
select {
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
err = fmt.Errorf("get gravatar image %s timeout", this.Hash)
|
err = fmt.Errorf("get gravatar image %s timeout", this.Hash)
|
||||||
|
Loading…
Reference in New Issue
Block a user