hugolib: Ignore non-source files on partial rebuild
authorxofyarg <xofyarg@users.noreply.github.com>
Sat, 22 Apr 2017 20:38:54 +0000 (21:38 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 22 Apr 2017 20:38:54 +0000 (22:38 +0200)
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.

hugolib/site.go
source/filesystem.go

index 3b7d47533ab9cb4b04ff14a2beaef1c24db60258..f2ebee4ccab4a22c2ac7a6a194d99b65d0cbfb12 100644 (file)
@@ -728,6 +728,9 @@ func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) {
                go pageConverter(pageChan, convertResults, wg2)
        }
 
+       sp := source.NewSourceSpec(s.Cfg, s.Fs)
+       fs := sp.NewFilesystem("")
+
        for _, ev := range sourceChanged {
                // The incrementalReadCollator below will also make changes to the site's pages,
                // so we do this first to prevent races.
@@ -750,6 +753,15 @@ func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) {
                        }
                }
 
+               // ignore files shouldn't be proceed
+               if fi, err := s.Fs.Source.Stat(ev.Name); err != nil {
+                       continue
+               } else {
+                       if ok, err := fs.ShouldRead(ev.Name, fi); err != nil || !ok {
+                               continue
+                       }
+               }
+
                sourceReallyChanged = append(sourceReallyChanged, ev)
        }
 
index a13128144335deb69d4ec79dbf97644b8122f8e9..ceea96ea5d0b4545ad3b87e7f29a0031f469a5ae 100644 (file)
@@ -90,7 +90,7 @@ func (f *Filesystem) captureFiles() {
                        return nil
                }
 
-               b, err := f.shouldRead(filePath, fi)
+               b, err := f.ShouldRead(filePath, fi)
                if err != nil {
                        return err
                }
@@ -118,7 +118,7 @@ func (f *Filesystem) captureFiles() {
 
 }
 
-func (f *Filesystem) shouldRead(filePath string, fi os.FileInfo) (bool, error) {
+func (f *Filesystem) ShouldRead(filePath string, fi os.FileInfo) (bool, error) {
        if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
                link, err := filepath.EvalSymlinks(filePath)
                if err != nil {