From f4ea5b63f3539de1e2f08257db43cb2002ec65d0 Mon Sep 17 00:00:00 2001 From: Pacien Date: Mon, 1 Jul 2013 15:46:54 +0200 Subject: Fix go routines sync delays --- interactive.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'interactive.go') diff --git a/interactive.go b/interactive.go index 1c9ca71..1baa4cc 100644 --- a/interactive.go +++ b/interactive.go @@ -26,7 +26,6 @@ import ( "os" "path" "strings" - "time" ) func watch(dirPath string, watcher *fsnotify.Watcher) *fsnotify.Watcher { @@ -107,21 +106,21 @@ func interactive(sourceDir, outputDir string, exts []string, saveAs string) { if fcmd.IsDir(ev.Name) { elements := parseParents(ev.Name, sourceDir, exts) dirPath := path.Join(sourceDir, strings.TrimPrefix(ev.Name, sourceDir)) + wait.Add(2) go compile(dirPath, elements, sourceDir, outputDir, saveAs, exts, true) go copyFiles(dirPath, sourceDir, outputDir, exts, true) } else { dirPath := path.Join(sourceDir, strings.TrimPrefix(dir, sourceDir)) if isParsable(path.Ext(ev.Name), exts) { elements := parseParents(dir, sourceDir, exts) + wait.Add(1) go compile(dirPath, elements, sourceDir, outputDir, saveAs, exts, true) } + wait.Add(1) go copyFiles(dirPath, sourceDir, outputDir, exts, false) } } - // sleep some milliseconds to prevent early exit - time.Sleep(time.Millisecond * 100) - // wait until all tasks are completed wait.Wait() -- cgit v1.2.3