#87 should be definitely fixed

This commit is contained in:
alessio 2017-09-18 19:39:24 +02:00
parent fb1ebdfe4f
commit 5f1ca705e1
1 changed files with 19 additions and 22 deletions

View File

@ -61,9 +61,8 @@ L:
select { select {
case event := <-watcher.Events: case event := <-watcher.Events:
if time.Now().Truncate(time.Second).After(p.lastChangedOn) { if time.Now().Truncate(time.Second).After(p.lastChangedOn) {
p.lastChangedOn = time.Now().Truncate(time.Second) file, err := os.Lstat(event.Name)
if file, err := os.Lstat(event.Name); err == nil { if (event.Op&fsnotify.Remove == fsnotify.Remove) || err == nil && file.Size() > 0 {
if file.Size() > 0 {
p.lastChangedOn = time.Now().Truncate(time.Second) p.lastChangedOn = time.Now().Truncate(time.Second)
ext := filepath.Ext(event.Name) ext := filepath.Ext(event.Name)
if inArray(ext, p.Watcher.Exts) { if inArray(ext, p.Watcher.Exts) {
@ -77,7 +76,6 @@ L:
p.stamp("log", out, msg, "") p.stamp("log", out, msg, "")
// check if is deleted // check if is deleted
if event.Op&fsnotify.Remove == fsnotify.Remove { if event.Op&fsnotify.Remove == fsnotify.Remove {
watcher.Remove(event.Name)
go p.routines(&wr, channel, watcher, "") go p.routines(&wr, channel, watcher, "")
} else { } else {
go p.routines(&wr, channel, watcher, event.Name) go p.routines(&wr, channel, watcher, event.Name)
@ -86,7 +84,6 @@ L:
} }
} }
} }
}
case err := <-watcher.Errors: case err := <-watcher.Errors:
msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular(err.Error())) msg = fmt.Sprintln(p.pname(p.Name, 2), ":", style.Red.Regular(err.Error()))
out = BufferOut{Time: time.Now(), Text: err.Error()} out = BufferOut{Time: time.Now(), Text: err.Error()}