Browse Source

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

Matt Landis 6 years ago
parent
commit
9c7f7bc0fa
3 changed files with 6 additions and 11 deletions
  1. 0 8
      pkg/watch/ospath.go
  2. 3 2
      pkg/watch/watcher_darwin.go
  3. 3 1
      pkg/watch/watcher_naive.go

+ 0 - 8
pkg/watch/ospath.go

@@ -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
-}

+ 3 - 2
pkg/watch/watcher_darwin.go

@@ -5,6 +5,8 @@ import (
 	"sync"
 	"time"
 
+	"github.com/windmilleng/tilt/internal/ospath"
+
 	"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
 	// we're already watching.
 	for _, parent := range es.Paths {
-		isChild := pathIsChildOf(name, parent)
-		if isChild {
+		if ospath.IsChild(parent, name) {
 			return nil
 		}
 	}

+ 3 - 1
pkg/watch/watcher_naive.go

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