diff options
author | Pacien | 2013-07-01 15:46:54 +0200 |
---|---|---|
committer | Pacien | 2013-07-01 15:46:54 +0200 |
commit | f4ea5b63f3539de1e2f08257db43cb2002ec65d0 (patch) | |
tree | 11f8aef2dc25e68f8ae9063391a132cb3c5777a1 /interactive.go | |
parent | c879511377bdb76615b58b212f030e82fb88d3be (diff) | |
download | foldaweb-f4ea5b63f3539de1e2f08257db43cb2002ec65d0.tar.gz |
Fix go routines sync delays
Diffstat (limited to 'interactive.go')
-rw-r--r-- | interactive.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/interactive.go b/interactive.go index 1c9ca71..1baa4cc 100644 --- a/interactive.go +++ b/interactive.go | |||
@@ -26,7 +26,6 @@ import ( | |||
26 | "os" | 26 | "os" |
27 | "path" | 27 | "path" |
28 | "strings" | 28 | "strings" |
29 | "time" | ||
30 | ) | 29 | ) |
31 | 30 | ||
32 | func watch(dirPath string, watcher *fsnotify.Watcher) *fsnotify.Watcher { | 31 | func watch(dirPath string, watcher *fsnotify.Watcher) *fsnotify.Watcher { |
@@ -107,21 +106,21 @@ func interactive(sourceDir, outputDir string, exts []string, saveAs string) { | |||
107 | if fcmd.IsDir(ev.Name) { | 106 | if fcmd.IsDir(ev.Name) { |
108 | elements := parseParents(ev.Name, sourceDir, exts) | 107 | elements := parseParents(ev.Name, sourceDir, exts) |
109 | dirPath := path.Join(sourceDir, strings.TrimPrefix(ev.Name, sourceDir)) | 108 | dirPath := path.Join(sourceDir, strings.TrimPrefix(ev.Name, sourceDir)) |
109 | wait.Add(2) | ||
110 | go compile(dirPath, elements, sourceDir, outputDir, saveAs, exts, true) | 110 | go compile(dirPath, elements, sourceDir, outputDir, saveAs, exts, true) |
111 | go copyFiles(dirPath, sourceDir, outputDir, exts, true) | 111 | go copyFiles(dirPath, sourceDir, outputDir, exts, true) |
112 | } else { | 112 | } else { |
113 | dirPath := path.Join(sourceDir, strings.TrimPrefix(dir, sourceDir)) | 113 | dirPath := path.Join(sourceDir, strings.TrimPrefix(dir, sourceDir)) |
114 | if isParsable(path.Ext(ev.Name), exts) { | 114 | if isParsable(path.Ext(ev.Name), exts) { |
115 | elements := parseParents(dir, sourceDir, exts) | 115 | elements := parseParents(dir, sourceDir, exts) |
116 | wait.Add(1) | ||
116 | go compile(dirPath, elements, sourceDir, outputDir, saveAs, exts, true) | 117 | go compile(dirPath, elements, sourceDir, outputDir, saveAs, exts, true) |
117 | } | 118 | } |
119 | wait.Add(1) | ||
118 | go copyFiles(dirPath, sourceDir, outputDir, exts, false) | 120 | go copyFiles(dirPath, sourceDir, outputDir, exts, false) |
119 | } | 121 | } |
120 | } | 122 | } |
121 | 123 | ||
122 | // sleep some milliseconds to prevent early exit | ||
123 | time.Sleep(time.Millisecond * 100) | ||
124 | |||
125 | // wait until all tasks are completed | 124 | // wait until all tasks are completed |
126 | wait.Wait() | 125 | wait.Wait() |
127 | 126 | ||