Handle errors during rereading properly
authorSteve Francia <steve.francia@gmail.com>
Thu, 2 Jun 2016 20:47:28 +0000 (16:47 -0400)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 2 Jun 2016 21:47:30 +0000 (23:47 +0200)
Without this fix, any error during rereading would cause Hugo to hang.
Fixes #2168
Closes #2179

hugolib/site.go

index 7537fe8fdea5d72811f34c6ada990ae7739330c9..bbbacb4a8329cbd0358b643d5d9086f9c6b07cbe 100644 (file)
@@ -505,11 +505,15 @@ func (s *Site) ReBuild(events []fsnotify.Event) error {
                }
 
                file, err := s.reReadFile(ev.Name)
+
                if err != nil {
-                       errs <- err
+                       jww.ERROR.Println("Error reading file", ev.Name, ";", err)
+               }
+
+               if file != nil {
+                       filechan <- file
                }
 
-               filechan <- file
        }
        // we close the filechan as we have sent everything we want to send to it.
        // this will tell the sourceReaders to stop iterating on that channel
@@ -559,8 +563,8 @@ func (s *Site) ReBuild(events []fsnotify.Event) error {
 
                return nil
        }
-       return err
 
+       return err
 }
 
 func (s *Site) Analyze() error {
@@ -835,7 +839,6 @@ func (s *Site) reReadFile(absFilePath string) (*source.File, error) {
        if err != nil {
                return nil, err
        }
-
        file, err = source.NewFileFromAbs(s.absContentDir(), absFilePath, reader)
 
        if err != nil {