add defer nil
This commit is contained in:
parent
de41ceddc4
commit
63a6856e45
@ -94,6 +94,11 @@ func GetOriginImage(c *context.Context) {
|
|||||||
c.ServerError(nil)
|
c.ServerError(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
buf.Reset()
|
||||||
|
buf = nil
|
||||||
|
}()
|
||||||
|
|
||||||
c.Writer.Header().Set("Content-Type", "image/jpeg")
|
c.Writer.Header().Set("Content-Type", "image/jpeg")
|
||||||
c.Writer.Header().Set("Content-Length", strconv.Itoa(buf.Len()))
|
c.Writer.Header().Set("Content-Length", strconv.Itoa(buf.Len()))
|
||||||
_, err = c.Writer.Write(buf.Bytes())
|
_, err = c.Writer.Write(buf.Bytes())
|
||||||
@ -116,6 +121,9 @@ func GetOriginImage(c *context.Context) {
|
|||||||
c.ServerError(nil)
|
c.ServerError(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
buf = nil
|
||||||
|
}()
|
||||||
|
|
||||||
c.Writer.Header().Set("Content-Type", "image/jpeg")
|
c.Writer.Header().Set("Content-Type", "image/jpeg")
|
||||||
io.Copy(c.Writer, buf)
|
io.Copy(c.Writer, buf)
|
||||||
@ -192,7 +200,12 @@ func GetThumbnailImage(c *context.Context) {
|
|||||||
c.ServerError(nil)
|
c.ServerError(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
breader := bytes.NewReader(buf.Bytes())
|
breader := bytes.NewReader(buf.Bytes())
|
||||||
|
defer func() {
|
||||||
|
buf = nil
|
||||||
|
breader = nil
|
||||||
|
}()
|
||||||
|
|
||||||
if genNew {
|
if genNew {
|
||||||
savep := path.Join(conf.ImageRoot, "thumbnail", subd, fname)
|
savep := path.Join(conf.ImageRoot, "thumbnail", subd, fname)
|
||||||
@ -227,6 +240,10 @@ func GetThumbnailImage(c *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
breader := bytes.NewReader(buf.Bytes())
|
breader := bytes.NewReader(buf.Bytes())
|
||||||
|
defer func() {
|
||||||
|
buf = nil
|
||||||
|
breader = nil
|
||||||
|
}()
|
||||||
|
|
||||||
savep := path.Join(conf.ImageRoot, "thumbnail", fname)
|
savep := path.Join(conf.ImageRoot, "thumbnail", fname)
|
||||||
err = saveNewThumbnail(breader, savep)
|
err = saveNewThumbnail(breader, savep)
|
||||||
|
Loading…
Reference in New Issue
Block a user