ignoreMissing flag
This commit is contained in:
parent
50b1c7205d
commit
1e15e2b753
@ -7,6 +7,7 @@ directories:
|
|||||||
events: ["CLOSE_WRITE", "MOVED_TO"]
|
events: ["CLOSE_WRITE", "MOVED_TO"]
|
||||||
pollingInterval: 60
|
pollingInterval: 60
|
||||||
regex: "/[^\\.][^/]+.xml$"
|
regex: "/[^\\.][^/]+.xml$"
|
||||||
|
ignoreMissing: true
|
||||||
actions:
|
actions:
|
||||||
- id: postXML
|
- id: postXML
|
||||||
description: POST xml
|
description: POST xml
|
||||||
|
17
main.go
17
main.go
@ -57,6 +57,7 @@ type DirectoryConfig struct {
|
|||||||
Events []string
|
Events []string
|
||||||
PollingInterval *int64 `yaml:"pollingInterval"`
|
PollingInterval *int64 `yaml:"pollingInterval"`
|
||||||
Regex *string
|
Regex *string
|
||||||
|
IgnoreMissing bool
|
||||||
_regex *regexp.Regexp
|
_regex *regexp.Regexp
|
||||||
_regexMatches []string
|
_regexMatches []string
|
||||||
Actions []ActionConfig
|
Actions []ActionConfig
|
||||||
@ -175,11 +176,17 @@ func startWatcher(directory *DirectoryConfig) {
|
|||||||
directory._regexMatches = directory._regex.FindStringSubmatch(p)
|
directory._regexMatches = directory._regex.FindStringSubmatch(p)
|
||||||
}
|
}
|
||||||
if directory._regex == nil || directory._regexMatches != nil {
|
if directory._regex == nil || directory._regexMatches != nil {
|
||||||
for _, action := range directory.Actions {
|
var statErr error
|
||||||
action.Directory = directory
|
if directory.IgnoreMissing {
|
||||||
contin, _ := runAction(&action, eventInfo, nil)
|
_, statErr = os.Stat(p)
|
||||||
if !contin {
|
}
|
||||||
break
|
if directory.IgnoreMissing || !os.IsNotExist(statErr) {
|
||||||
|
for _, action := range directory.Actions {
|
||||||
|
action.Directory = directory
|
||||||
|
contin, _ := runAction(&action, eventInfo, nil)
|
||||||
|
if !contin {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user