Skip to content

Commit

Permalink
Fix error handling for caching of stream responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Dino Omanovic committed Jul 11, 2016
1 parent c3f7411 commit f0d05ba
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions composition/cache_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ func (loader *CachingContentLoader) Load(fd *FetchDefinition) (Content, error) {
if c.Reader() != nil {
var streamBytes []byte
streamBytes, err = ioutil.ReadAll(c.Reader())
cw := &ContentWrapper{
Content: c,
streamBytes: streamBytes,
if err == nil {
cw := &ContentWrapper{
Content: c,
streamBytes: streamBytes,
}
loader.cache.Set(hash, fd.URL, c.MemorySize(), cw)
c.SetReader(cw.Reader())
}
loader.cache.Set(hash, fd.URL, c.MemorySize(), cw)
c.SetReader(cw.Reader())
} else {
loader.cache.Set(hash, fd.URL, c.MemorySize(), c)
}
Expand Down

0 comments on commit f0d05ba

Please sign in to comment.