Skip to content

Commit b5b6e81

Browse files
xofyargbep
authored andcommitted
hugolib: Ignore non-source files on partial rebuild
Partial rebuild does not have the same logic as normal rebuild on selecting which file to build. This change makes it possible to share the file select logic between two kinds of build. Fix #3325.
1 parent 90d3fbf commit b5b6e81

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

‎hugolib/site.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) {
728728
go pageConverter(pageChan, convertResults, wg2)
729729
}
730730

731+
sp := source.NewSourceSpec(s.Cfg, s.Fs)
732+
fs := sp.NewFilesystem("")
733+
731734
for _, ev := range sourceChanged {
732735
// The incrementalReadCollator below will also make changes to the site's pages,
733736
// so we do this first to prevent races.
@@ -750,6 +753,15 @@ func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) {
750753
}
751754
}
752755

756+
// ignore files shouldn't be proceed
757+
if fi, err := s.Fs.Source.Stat(ev.Name); err != nil {
758+
continue
759+
} else {
760+
if ok, err := fs.ShouldRead(ev.Name, fi); err != nil || !ok {
761+
continue
762+
}
763+
}
764+
753765
sourceReallyChanged = append(sourceReallyChanged, ev)
754766
}
755767

‎source/filesystem.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (f *Filesystem) captureFiles() {
9090
return nil
9191
}
9292

93-
b, err := f.shouldRead(filePath, fi)
93+
b, err := f.ShouldRead(filePath, fi)
9494
if err != nil {
9595
return err
9696
}
@@ -118,7 +118,7 @@ func (f *Filesystem) captureFiles() {
118118

119119
}
120120

121-
func (f *Filesystem) shouldRead(filePath string, fi os.FileInfo) (bool, error) {
121+
func (f *Filesystem) ShouldRead(filePath string, fi os.FileInfo) (bool, error) {
122122
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
123123
link, err := filepath.EvalSymlinks(filePath)
124124
if err != nil {

0 commit comments

Comments
 (0)