live_update: error if syncing from outside of docker context (#1396)

This commit is contained in:
Matt Landis 2019-04-01 16:51:43 -04:00 committed by Nicolas De loof
parent 6defe7cac6
commit 9c7f7bc0fa
3 changed files with 6 additions and 11 deletions

View File

@ -1,8 +0,0 @@
package watch
import "github.com/windmilleng/tilt/internal/ospath"
func pathIsChildOf(path string, parent string) bool {
_, isChild := ospath.Child(parent, path)
return isChild
}

View File

@ -5,6 +5,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/windmilleng/tilt/internal/ospath"
"github.com/windmilleng/fsevents" "github.com/windmilleng/fsevents"
) )
@ -77,8 +79,7 @@ func (d *darwinNotify) Add(name string) error {
// Check if this is a subdirectory of any of the paths // Check if this is a subdirectory of any of the paths
// we're already watching. // we're already watching.
for _, parent := range es.Paths { for _, parent := range es.Paths {
isChild := pathIsChildOf(name, parent) if ospath.IsChild(parent, name) {
if isChild {
return nil return nil
} }
} }

View File

@ -10,6 +10,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/windmilleng/fsnotify" "github.com/windmilleng/fsnotify"
"github.com/windmilleng/tilt/internal/ospath"
) )
// A naive file watcher that uses the plain fsnotify API. // A naive file watcher that uses the plain fsnotify API.
@ -151,7 +153,7 @@ func (d *naiveNotify) shouldNotify(e fsnotify.Event) bool {
} else { } else {
// TODO(dmiller): maybe use a prefix tree here? // TODO(dmiller): maybe use a prefix tree here?
for path := range d.notifyList { for path := range d.notifyList {
if pathIsChildOf(e.Name, path) { if ospath.IsChild(path, e.Name) {
return true return true
} }
} }