Skip to content

Commit

Permalink
add data-config event .ExtName filter
Browse files Browse the repository at this point in the history
  • Loading branch information
qq358860528 authored Dec 1, 2023
1 parent d5b368c commit 3f34851
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/data-config/source_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/radovskyb/watcher"
"os"
"time"
"regexp"
)

type (
Expand Down Expand Up @@ -39,6 +40,13 @@ func (f *SourceFile) Init(_ IDataConfig) {

f.watcher = watcher.New()
f.watcher.FilterOps(watcher.Write)
var regexpFilter * regexp.Regexp
regexpFilter,err = regexp.Compile(`.*\`+f.ExtName+`$`)
if err != nil {
clog.Panicf("AddFilterHook extName fail. err = %v", err)
return
}
f.watcher.AddFilterHook(watcher.RegexFilterHook(regexpFilter, false))

f.monitorPath, err = cfile.JoinPath(cprofile.Path(), f.FilePath)
if err != nil {
Expand Down

0 comments on commit 3f34851

Please sign in to comment.