From 2a16609bf730edfb4e28c85c131c9518186685be Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 7 Mar 2018 22:11:58 -0600 Subject: [PATCH] avoud double encoding --- app/rest/auth/avatar.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/rest/auth/avatar.go b/app/rest/auth/avatar.go index 300fd5a4..3074eb24 100644 --- a/app/rest/auth/avatar.go +++ b/app/rest/auth/avatar.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "path" + "strconv" "strings" "time" @@ -53,8 +54,11 @@ func (p *AvatarProxy) Put(u store.User) (avatarURL string, err error) { }() // get ID and location of locally cached avatar - encID := rest.EncodeID(u.ID) - location := p.location(encID) // location adds partion to path + encID := u.ID // all locally created comments have userID encoded hex, imported extra need encoding. + if _, err := strconv.ParseUint(u.ID, 16, 64); err != nil { + encID = rest.EncodeID(u.ID) + } + location := p.location(u.ID) // location adds partion to path if _, err = os.Stat(location); os.IsNotExist(err) { if e := os.Mkdir(location, 0700); e != nil {