Nothing Special   »   [go: up one dir, main page]

Skip to content

Commit

Permalink
Merge pull request #184 from robcapo/master
Browse files Browse the repository at this point in the history
Fixed walking large directory issue
  • Loading branch information
asoseil authored May 11, 2018
2 parents 269ade5 + 1faa523 commit 49d3795
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion realize.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/oxequa/interact"
"github.com/oxequa/realize/realize"
"github.com/robcapo/realize/realize"
"gopkg.in/urfave/cli.v2"
"log"
"os"
Expand Down
27 changes: 19 additions & 8 deletions realize/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,8 @@ func (p *Project) Validate(path string, fcheck bool) bool {
}
}
}
separator := string(os.PathSeparator)
// supported paths
for _, v := range p.Watcher.Ignore {
s := append([]string{p.Path}, strings.Split(v, separator)...)
abs, _ := filepath.Abs(filepath.Join(s...))
if path == abs || strings.HasPrefix(path, abs+separator) {
return false
}
if p.shouldIgnore(path) {
return false
}
// file check
if fcheck {
Expand Down Expand Up @@ -492,6 +486,10 @@ func (p *Project) cmd(stop <-chan bool, flag string, global bool) {

// Watch the files tree of a project
func (p *Project) walk(path string, info os.FileInfo, err error) error {
if p.shouldIgnore(path) {
return filepath.SkipDir
}

if p.Validate(path, true) {
result := p.watcher.Walk(path, p.init)
if result != "" {
Expand All @@ -511,6 +509,19 @@ func (p *Project) walk(path string, info os.FileInfo, err error) error {
return nil
}

func (p *Project) shouldIgnore(path string) bool {
separator := string(os.PathSeparator)
// supported paths
for _, v := range p.Watcher.Ignore {
s := append([]string{p.Path}, strings.Split(v, separator)...)
abs, _ := filepath.Abs(filepath.Join(s...))
if path == abs || strings.HasPrefix(path, abs+separator) {
return true
}
}
return false
}

// Print on files, cli, ws
func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
ctime := time.Now()
Expand Down

0 comments on commit 49d3795

Please sign in to comment.