mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 06:30:33 +03:00
resources/images: Make the image cache more robust
Also allow timeout to be set as a duration string, e.g. `30s`. Fixes #6501
This commit is contained in:
parent
031f948f87
commit
d6f7a9e28d
11 changed files with 85 additions and 32 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue