diff options
Diffstat (limited to 'hugofs')
-rw-r--r-- | hugofs/fs.go | 4 | ||||
-rw-r--r-- | hugofs/hasbytes_fs.go | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/hugofs/fs.go b/hugofs/fs.go index 63c25a4c0..51bbe0619 100644 --- a/hugofs/fs.go +++ b/hugofs/fs.go @@ -40,8 +40,7 @@ type Fs struct { // It's mounted inside publishDir (default /public). PublishDir afero.Fs - // PublishDirStatic is the file system used for static files when --renderStaticToDisk is set. - // When this is set, PublishDir is set to write to memory. + // PublishDirStatic is the file system used for static files. PublishDirStatic afero.Fs // PublishDirServer is the file system used for serving the public directory with Hugo's development server. @@ -142,7 +141,6 @@ func isWrite(flag int) bool { // MakeReadableAndRemoveAllModulePkgDir makes any subdir in dir readable and then // removes the root. // TODO(bep) move this to a more suitable place. -// func MakeReadableAndRemoveAllModulePkgDir(fs afero.Fs, dir string) (int, error) { // Safe guard if !strings.Contains(dir, "pkg") { diff --git a/hugofs/hasbytes_fs.go b/hugofs/hasbytes_fs.go index b5f82877e..3d32a828f 100644 --- a/hugofs/hasbytes_fs.go +++ b/hugofs/hasbytes_fs.go @@ -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{ |