diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-11-25 12:49:04 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-11-25 18:59:06 +0100 |
commit | d6f7a9e28dfd5abff08b6aaf6fb3493c46bd1e39 (patch) | |
tree | f5715b86cff28eb5c7ab7320c30a492806441cae /resources/image_cache.go | |
parent | 031f948f87ac97ca49d0a487a392a8a0c6afb699 (diff) |
resources/images: Make the image cache more robust
Also allow timeout to be set as a duration string, e.g. `30s`.
Fixes #6501
Diffstat (limited to 'resources/image_cache.go')
-rw-r--r-- | resources/image_cache.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/resources/image_cache.go b/resources/image_cache.go index 9192a8e43..f57d73ede 100644 --- a/resources/image_cache.go +++ b/resources/image_cache.go @@ -96,12 +96,18 @@ func (c *imageCache) getOrCreate( // These funcs are protected by a named lock. // read clones the parent to its new name and copies // the content to the destinations. - read := func(info filecache.ItemInfo, r io.Reader) error { + read := func(info filecache.ItemInfo, r io.ReadSeeker) error { img = parent.clone(nil) rp := img.getResourcePaths() rp.relTargetDirFile.file = relTarget.file img.setSourceFilename(info.Name) + if err := img.InitConfig(r); err != nil { + return err + } + + r.Seek(0, 0) + w, err := img.openDestinationsForWriting() if err != nil { return err @@ -114,6 +120,7 @@ func (c *imageCache) getOrCreate( defer w.Close() _, err = io.Copy(w, r) + return err } |