mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
Fix /static performance regression from Hugo 0.103.0
In `v0.103.0` we added support for `resources.PostProcess` for all file types, not just HTML. We had benchmarks that said we were fine in that department, but those did not consider the static file syncing. This fixes that by: * Making sure that the /static syncer always gets its own file system without any checks for the post process token. * For dynamic files (e.g. rendered HTML files) we add an additional check to make sure that we skip binary files (e.g. images) Fixes #10328
This commit is contained in:
@@ -27,12 +27,13 @@ var (
|
||||
|
||||
type hasBytesFs struct {
|
||||
afero.Fs
|
||||
shouldCheck func(name string) bool
|
||||
hasBytesCallback func(name string, match bool)
|
||||
pattern []byte
|
||||
}
|
||||
|
||||
func NewHasBytesReceiver(delegate afero.Fs, hasBytesCallback func(name string, match bool), pattern []byte) afero.Fs {
|
||||
return &hasBytesFs{Fs: delegate, hasBytesCallback: hasBytesCallback, pattern: pattern}
|
||||
func NewHasBytesReceiver(delegate afero.Fs, shouldCheck func(name string) bool, hasBytesCallback func(name string, match bool), pattern []byte) afero.Fs {
|
||||
return &hasBytesFs{Fs: delegate, shouldCheck: shouldCheck, hasBytesCallback: hasBytesCallback, pattern: pattern}
|
||||
}
|
||||
|
||||
func (fs *hasBytesFs) UnwrapFilesystem() afero.Fs {
|
||||
@@ -56,6 +57,9 @@ func (fs *hasBytesFs) OpenFile(name string, flag int, perm os.FileMode) (afero.F
|
||||
}
|
||||
|
||||
func (fs *hasBytesFs) wrapFile(f afero.File) afero.File {
|
||||
if !fs.shouldCheck(f.Name()) {
|
||||
return f
|
||||
}
|
||||
return &hasBytesFile{
|
||||
File: f,
|
||||
hbw: &hugio.HasBytesWriter{
|
||||
|
Reference in New Issue
Block a user