Fixed problems for directories with the same names

This commit is contained in:
alessio 2016-08-14 17:22:20 +02:00
parent a0a17cff8b
commit 2dae8000e8
1 changed files with 24 additions and 5 deletions

View File

@ -25,7 +25,7 @@ func (h *Config) Watch() error {
// loop projects // loop projects
wg.Add(len(h.Projects)) wg.Add(len(h.Projects))
for k := range h.Projects { for k := range h.Projects {
if string(h.Projects[k].Path[0]) != "/" { if !slash(string(h.Projects[k].Path[0])) {
h.Projects[k].Path = "/" + h.Projects[k].Path h.Projects[k].Path = "/" + h.Projects[k].Path
} }
go h.Projects[k].Watching() go h.Projects[k].Watching()
@ -69,12 +69,20 @@ func (p *Project) Watching() {
return return
} }
// check paths existence // check paths existence
if _, err := os.Stat(base + p.Path + dir); err == nil { if slash(dir) {
if err := filepath.Walk(base + p.Path + dir, walk); err != nil { base = base + p.Path
}else{
base = base + p.Path + dir
}
if _, err := os.Stat(base); err == nil {
if err := filepath.Walk(base, walk); err != nil {
Fail(err.Error()) Fail(err.Error())
} }
if slash(dir) {
break
}
} else { } else {
Fail(p.Name + ": \t" + base + p.Path + dir + " path doesn't exist") Fail(p.Name + ": \t" + base + " path doesn't exist")
} }
} }
@ -157,10 +165,21 @@ func InArray(str string, list []string) bool {
} }
func Ignore(str string, list []string) bool { func Ignore(str string, list []string) bool {
base, _ := os.Getwd()
for _, v := range list { for _, v := range list {
if strings.Contains(str, v) { if !slash(v) {
v = "/" +v
}
if strings.Contains(str, base + v) {
return true return true
} }
} }
return false return false
}
func slash(str string) bool{
if string(str[0]) == "/" {
return true
}
return false
} }