debug option

This commit is contained in:
asoseil 2017-12-27 12:38:43 +01:00
parent 7b8adb788d
commit 5929e65b9d
2 changed files with 7 additions and 3 deletions

View File

@ -284,6 +284,9 @@ L:
for {
select {
case event := <-p.watcher.Events():
if p.parent.Settings.Debug {
log.Println("Event:", event, "File:", event.Name, "LastFile:", p.lastFile, "Time:", time.Second, "LastTime:", p.lastTime)
}
if time.Now().Truncate(time.Second).After(p.lastTime) || event.Name != p.lastFile {
// event time
eventTime := time.Now()
@ -308,7 +311,7 @@ L:
if fi.IsDir() {
filepath.Walk(event.Name, p.walk)
} else {
if event.Op != fsnotify.Write || (eventTime.Truncate(time.Millisecond).After(fi.ModTime().Truncate(time.Millisecond)) || event.Name != p.lastFile) {
if event.Op != fsnotify.Write || (!eventTime.Truncate(time.Millisecond).Before(fi.ModTime().Truncate(time.Millisecond)) || event.Name != p.lastFile) {
// stop and restart
close(p.stop)
p.stop = make(chan bool)

View File

@ -29,9 +29,10 @@ const (
// Settings defines a group of general settings and options
type Settings struct {
Files `yaml:"files,omitempty" json:"files,omitempty"`
Legacy Legacy `yaml:"legacy" json:"legacy"`
FileLimit int32 `yaml:"flimit,omitempty" json:"flimit,omitempty"`
Recovery bool `yaml:"recovery,omitempty" json:"recovery,omitempty"`
Debug bool `yaml:"debug,omitempty" json:"debug,omitempty"`
FileLimit int32 `yaml:"flimit,omitempty" json:"flimit,omitempty"`
Legacy Legacy `yaml:"legacy" json:"legacy"`
}
// Legacy is used to force polling and set a custom interval