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