shithub: hugo

Download patch

ref: 49a104309d53af243b32443a59bdc2a6fc9beeef
parent: 5be0448635fdf5fe6b1ee673e869f2b9baf1a5c6
author: Bjørn Erik Pedersen <[email protected]>
date: Wed Jun 7 18:11:15 EDT 2017

hugolib: Fix live-reload regression for add/removal of dirs

This reverts commit b5b6e81c0269abf9b0f4bc6a127744a25344e5c6.

That change breaks watching of new directories (new dirs, deleted dirs).

Reopens #3325
Fixes #3569

--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -753,9 +753,6 @@
 		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.
@@ -774,15 +771,6 @@
 			if ex, err := afero.Exists(s.Fs.Source, ev.Name); !ex || err != nil {
 				path, _ := helpers.GetRelativePath(ev.Name, s.getContentDir(ev.Name))
 				s.removePageByPath(path)
-				continue
-			}
-		}
-
-		// 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
 			}
 		}
--- a/source/filesystem.go
+++ b/source/filesystem.go
@@ -90,7 +90,7 @@
 			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) 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 {