From fe07d124db53ac231b4037849ad7697a24fa347e Mon Sep 17 00:00:00 2001 From: Rob Capo Date: Fri, 11 May 2018 09:37:27 -0400 Subject: [PATCH 1/2] Fixed walking large directory issue --- realize/projects.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/realize/projects.go b/realize/projects.go index f2a5f0a..c218e95 100644 --- a/realize/projects.go +++ b/realize/projects.go @@ -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 { @@ -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 != "" { @@ -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() From 1faa5231123e7e61ef8113663e05b5a397f2df40 Mon Sep 17 00:00:00 2001 From: Rob Capo Date: Fri, 11 May 2018 09:50:56 -0400 Subject: [PATCH 2/2] Fixed ref --- realize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/realize.go b/realize.go index 8bd6e23..b41ed80 100644 --- a/realize.go +++ b/realize.go @@ -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"