mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
resource: Move opening of the transformed resources after cache check
The old version should be functionally the same, but opening up these readers (potentially files) every time is wasteful if we don't read from them.
This commit is contained in:
parent
beec1fc98e
commit
0024dcfe3e
1 changed files with 8 additions and 6 deletions
|
@ -303,12 +303,6 @@ func (r *transformedResource) transform(setContent bool) (err error) {
|
|||
|
||||
first := chain[0]
|
||||
|
||||
contentrc, err := contentReadSeekerCloser(first)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer contentrc.Close()
|
||||
|
||||
// Files with a suffix will be stored in cache (both on disk and in memory)
|
||||
// partitioned by their suffix. There will be other files below /other.
|
||||
// This partition is also how we determine what to delete on server reloads.
|
||||
|
@ -347,6 +341,7 @@ func (r *transformedResource) transform(setContent bool) (err error) {
|
|||
r.cache.nlocker.Unlock(key)
|
||||
return
|
||||
}
|
||||
|
||||
defer r.cache.nlocker.Unlock(key)
|
||||
defer r.cache.set(key, r)
|
||||
|
||||
|
@ -362,6 +357,13 @@ func (r *transformedResource) transform(setContent bool) (err error) {
|
|||
|
||||
tctx.InMediaType = first.MediaType()
|
||||
tctx.OutMediaType = first.MediaType()
|
||||
|
||||
contentrc, err := contentReadSeekerCloser(first)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer contentrc.Close()
|
||||
|
||||
tctx.From = contentrc
|
||||
tctx.To = b1
|
||||
|
||||
|
|
Loading…
Reference in a new issue