Merge pull request #184 from robcapo/master
Fixed walking large directory issue
This commit is contained in:
commit
49d37952b5
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/oxequa/interact"
|
"github.com/oxequa/interact"
|
||||||
"github.com/oxequa/realize/realize"
|
"github.com/robcapo/realize/realize"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
|
@ -372,15 +372,9 @@ func (p *Project) Validate(path string, fcheck bool) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
separator := string(os.PathSeparator)
|
if p.shouldIgnore(path) {
|
||||||
// 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
|
return false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// file check
|
// file check
|
||||||
if fcheck {
|
if fcheck {
|
||||||
fi, err := os.Stat(path)
|
fi, err := os.Stat(path)
|
||||||
|
@ -492,6 +486,10 @@ func (p *Project) cmd(stop <-chan bool, flag string, global bool) {
|
||||||
|
|
||||||
// Watch the files tree of a project
|
// Watch the files tree of a project
|
||||||
func (p *Project) walk(path string, info os.FileInfo, err error) error {
|
func (p *Project) walk(path string, info os.FileInfo, err error) error {
|
||||||
|
if p.shouldIgnore(path) {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
|
|
||||||
if p.Validate(path, true) {
|
if p.Validate(path, true) {
|
||||||
result := p.watcher.Walk(path, p.init)
|
result := p.watcher.Walk(path, p.init)
|
||||||
if result != "" {
|
if result != "" {
|
||||||
|
@ -511,6 +509,19 @@ func (p *Project) walk(path string, info os.FileInfo, err error) error {
|
||||||
return nil
|
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
|
// Print on files, cli, ws
|
||||||
func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
||||||
ctime := time.Now()
|
ctime := time.Now()
|
||||||
|
|
Loading…
Reference in New Issue