close #1508
This commit is contained in:
parent
f328eb3b9f
commit
490442aa1d
1 changed files with 8 additions and 0 deletions
|
|
@ -74,6 +74,7 @@ type watcher struct {
|
||||||
l net.Listener
|
l net.Listener
|
||||||
staticFileServer http.Handler
|
staticFileServer http.Handler
|
||||||
|
|
||||||
|
boardpathMu sync.Mutex
|
||||||
wsclientsMu sync.Mutex
|
wsclientsMu sync.Mutex
|
||||||
closing bool
|
closing bool
|
||||||
wsclientsWG sync.WaitGroup
|
wsclientsWG sync.WaitGroup
|
||||||
|
|
@ -424,7 +425,9 @@ func (w *watcher) compileLoop(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fs := trackedFS{}
|
fs := trackedFS{}
|
||||||
|
w.boardpathMu.Lock()
|
||||||
svg, _, err := compile(ctx, w.ms, w.plugins, &fs, w.layout, w.renderOpts, w.fontFamily, w.animateInterval, w.inputPath, w.outputPath, w.boardPath, w.bundle, w.forceAppendix, w.pw.Page)
|
svg, _, err := compile(ctx, w.ms, w.plugins, &fs, w.layout, w.renderOpts, w.fontFamily, w.animateInterval, w.inputPath, w.outputPath, w.boardPath, w.bundle, w.forceAppendix, w.pw.Page)
|
||||||
|
w.boardpathMu.Unlock()
|
||||||
errs := ""
|
errs := ""
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if len(svg) > 0 {
|
if len(svg) > 0 {
|
||||||
|
|
@ -507,13 +510,18 @@ func (w *watcher) handleRoot(hw http.ResponseWriter, r *http.Request) {
|
||||||
</body>
|
</body>
|
||||||
</html>`, filepath.Base(w.outputPath), w.devMode)
|
</html>`, filepath.Base(w.outputPath), w.devMode)
|
||||||
|
|
||||||
|
w.boardpathMu.Lock()
|
||||||
// if path is "/x.svg", we just want "x"
|
// if path is "/x.svg", we just want "x"
|
||||||
boardPath := strings.TrimPrefix(r.URL.Path, "/")
|
boardPath := strings.TrimPrefix(r.URL.Path, "/")
|
||||||
if idx := strings.LastIndexByte(boardPath, '.'); idx != -1 {
|
if idx := strings.LastIndexByte(boardPath, '.'); idx != -1 {
|
||||||
boardPath = boardPath[:idx]
|
boardPath = boardPath[:idx]
|
||||||
}
|
}
|
||||||
|
recompile := false
|
||||||
if boardPath != w.boardPath {
|
if boardPath != w.boardPath {
|
||||||
w.boardPath = boardPath
|
w.boardPath = boardPath
|
||||||
|
}
|
||||||
|
w.boardpathMu.Unlock()
|
||||||
|
if recompile {
|
||||||
w.requestCompile()
|
w.requestCompile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue