Skip to content

Commit

Permalink
build: adjust file sync server (#6104)
Browse files Browse the repository at this point in the history
the sync protocol should always send over the directory
file info when it sends over files in its subtree, even
if the directory path itself is marked as ignored

fixes #6102

Signed-off-by: Nick Santos <nick.santos@docker.com>
  • Loading branch information
nicks authored Apr 17, 2023
1 parent e6b6c0e commit e38e4a2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 3 additions & 1 deletion integration/ignores/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ignored_by_dockerignore.txt
ignored_by_dockerignore.txt
topdir
!topdir/subdir
1 change: 1 addition & 0 deletions integration/ignores/topdir/subdir/src.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world
4 changes: 4 additions & 0 deletions integration/ignores_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ func TestIgnores(t *testing.T) {
res, err = http.Get("http://localhost:31234/ignored_by_tiltfile.txt")
assert.NoError(t, err)
assert.Equal(t, res.StatusCode, http.StatusNotFound)

_, body, err = f.Curl("http://localhost:31234/topdir/subdir/src.txt")
assert.NoError(t, err)
assert.Contains(t, body, "hello")
}
19 changes: 10 additions & 9 deletions internal/build/docker_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,16 +566,17 @@ func toSyncedDirs(context string, dockerfileSyncDir string, filter model.PathMat
path = filepath.Join(context, path)
}

matches, _ := filter.Matches(path)
if matches {
isDir := s != nil && s.IsDir()
if isDir {
entireDir, _ := filter.MatchesEntireDir(path)
if entireDir {
return fsutil.MapResultSkipDir
}
isDir := s != nil && s.IsDir()
if isDir {
entireDir, _ := filter.MatchesEntireDir(path)
if entireDir {
return fsutil.MapResultSkipDir
}
} else {
matches, _ := filter.Matches(path)
if matches {
return fsutil.MapResultExclude
}
return fsutil.MapResultExclude
}
s.Uid = 0
s.Gid = 0
Expand Down

0 comments on commit e38e4a2

Please sign in to comment.