shithub: hugo

Download patch

ref: e46148f948db3b8d86e9bae6228d5981fcb3b006
parent: 065928fcf017b0ce6977fef666f7977f7f09b4d7
author: Egon Elbre <[email protected]>
date: Sun Dec 15 11:31:29 EST 2013

Fix static file change detection on Windows.
Fixed windows uses different filepath separator. The filepath.ToSlash
shouldn't be used, because it can cause errors in filepath suffix and prefix
testing since "c:\a" isn't a prefix of "c:/a/b/c".

--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -198,16 +198,20 @@
 }
 
 func watchChange(ev *fsnotify.FileEvent) {
+	ext := filepath.Ext(ev.Name)
+	// ignore temp files
+	istemp := strings.HasSuffix(ext, "~") || (ext == ".swp") || (ext == ".tmp")
+	if istemp {
+		return
+	}
+
 	if strings.HasPrefix(ev.Name, Config.GetAbsPath(Config.StaticDir)) {
 		fmt.Println("Static file changed, syncing\n")
 		utils.CheckErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", Config.GetAbsPath(Config.PublishDir)))
 	} else {
 		if !ev.IsRename() { // Rename is always accompanied by a create or modify
-			// Ignoring temp files created by editors (vim)
-			if !strings.HasSuffix(ev.Name, "~") && !strings.HasSuffix(ev.Name, ".swp") {
-				fmt.Println("Change detected, rebuilding site\n")
-				utils.StopOnErr(buildSite(true))
-			}
+			fmt.Println("Change detected, rebuilding site\n")
+			utils.StopOnErr(buildSite(true))
 		}
 	}
 }
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -161,7 +161,7 @@
 		return name
 	}
 
-	return filepath.ToSlash(filepath.Join(c.GetPath(), name))
+	return filepath.Join(c.GetPath(), name)
 }
 
 func (c *Config) findConfigFile(configFileName string) (string, error) {