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

fix: use ignore_paths while checking large projects during rill start #5164

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Changes from 1 commit
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
22 changes: 20 additions & 2 deletions cli/cmd/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"github.com/rilldata/rill/cli/pkg/gitutil"
"github.com/rilldata/rill/cli/pkg/local"
"github.com/rilldata/rill/runtime/compilers/rillv1beta"
"github.com/rilldata/rill/runtime/drivers"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)

// maxProjectFiles is the maximum number of files that can be in a project directory.
Expand Down Expand Up @@ -204,18 +206,34 @@ func StartCmd(ch *cmdutil.Helper) *cobra.Command {
return startCmd
}

// a smaller subset of relevant parts of rill.yaml
type rillYAML struct {
IgnorePaths []string `yaml:"ignore_paths"`
}

func countFilesInDirectory(path string) (int, error) {
var fileCount int

if path == "" {
path = "."
}

err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
var ignorePaths []string
// Read rill.yaml and get `ignore_paths`
rawYaml, err := os.ReadFile(filepath.Join(path, "/rill.yaml"))
if err == nil {
yml := &rillYAML{}
err = yaml.Unmarshal(rawYaml, yml)
if err == nil {
ignorePaths = yml.IgnorePaths
}
}

err = filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to filepath.WalkDir and return filepath.SkipDir if the path is ignored? So that it doesn't spend time traversing ignored directories.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, updated.

if err != nil {
return err
}
if !info.IsDir() {
if !info.IsDir() && drivers.IsIgnored(path, ignorePaths) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is tmp directly added to ignorePaths by default during project initialization?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileCount++
}
return nil
Expand Down
Loading