Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Optimized fs walker and util.IsEmptyDir #9433

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/skaffold/docker/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ func WalkWorkspace(workspace string, excludes, deps []string) (map[string]bool,
if err != nil {
return err
}
if util.IsEmptyDir(path) || !info.IsDir() {

if !info.IsDir() || util.IsEmptyDir(path) {
files[relPath] = true
}

Expand All @@ -277,5 +278,6 @@ func WalkWorkspace(workspace string, excludes, deps []string) (map[string]bool,
return nil, fmt.Errorf("walking %q: %w", absFrom, err)
}
}

return files, nil
}
9 changes: 4 additions & 5 deletions pkg/skaffold/docker/syncmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ func walkWorkspaceWithDestinations(workspace string, excludes []string, fts []Fr
switch mode := fi.Mode(); {
case mode.IsDir():
keepFile := func(path string, info walk.Dirent) (bool, error) {
if info.IsDir() && path == absFrom {
return true, nil
if info.IsDir() {
if path == absFrom || util.IsEmptyDir(path) {
return true, nil
}
}

if util.IsEmptyDir(path) {
return true, nil
}
ignored, err := dockerIgnored(path, info)
if err != nil {
return false, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func IsEmptyDir(path string) bool {
return false
}
defer d.Close()
if _, err := d.ReadDir(1); err == io.EOF {
if _, err := d.Readdirnames(1); err == io.EOF {
return true
}
return false
Expand Down
Loading