Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

Commit

Permalink
Just use the feed's own favicon URL
Browse files Browse the repository at this point in the history
I give up. Can't figure out why favicon images are being deleted.
  • Loading branch information
maddyblue committed Jul 4, 2014
1 parent 75c2618 commit ac1c378
Showing 1 changed file with 4 additions and 46 deletions.
50 changes: 4 additions & 46 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import (
"fmt"
"html"
"html/template"
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"io/ioutil"
"math/rand"
"net/http"
Expand All @@ -39,8 +35,6 @@ import (
"github.com/mjibson/goon"

"appengine"
"appengine/blobstore"
aimage "appengine/image"
"appengine/memcache"
"appengine/taskqueue"
"appengine/urlfetch"
Expand Down Expand Up @@ -677,48 +671,12 @@ func loadImage(c appengine.Context, f *Feed) {
if err != nil {
return
}
r, err := client.Get(u.String())
us := u.String()
r, err := client.Get(us)
if err != nil || r.StatusCode != http.StatusOK || r.ContentLength == 0 {
return
}
b, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
return
}
buf := bytes.NewBuffer(b)
_, t, err := image.DecodeConfig(buf)
if err != nil {
t = "application/octet-stream"
} else {
t = "image/" + t
}
w, err := blobstore.Create(c, t)
if err != nil {
return
}
if _, err := w.Write(b); err != nil {
return
}
if w.Close() != nil {
return
}
g := goon.FromContext(c)
i := &Image{Id: u.String()}
if err := g.Get(i); err == nil {
blobstore.Delete(c, i.Blob)
}
i.Blob, _ = w.Key()
su, err := aimage.ServingURL(c, i.Blob, &aimage.ServingURLOptions{Size: 16})
if err != nil {
if err = blobstore.Delete(c, i.Blob); err != nil {
c.Errorf("blob delete err: %v", err)
}
return
us = ""
}
i.Url = su.String()
g.Put(i)
f.Image = i.Url
f.Image = us
}

func updateAverage(f *Feed, previousUpdate time.Time, updateCount int) {
Expand Down

0 comments on commit ac1c378

Please sign in to comment.