Skip to content

Commit

Permalink
refactor codes
Browse files Browse the repository at this point in the history
  • Loading branch information
lyt122 committed Jul 15, 2024
1 parent 363dd1d commit b81b325
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions plugins/pkg/file/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ func (w *Watcher) AddFiles(files ...*File) error {
w.mu.Lock()
defer w.mu.Unlock()
for _, file := range files {
if _, exists := w.files[file.Name]; !exists {
w.files[file.Name] = true
}
dir, err := filepath.Abs(file.Name)
absPath, err := filepath.Abs(file.Name)
if err != nil {
return err

Check warning on line 61 in plugins/pkg/file/fs.go

View check run for this annotation

Codecov / codecov/patch

plugins/pkg/file/fs.go#L61

Added line #L61 was not covered by tests
}
if _, exists := w.files[absPath]; !exists {
w.files[absPath] = true
}

dir := filepath.Dir(absPath)
if _, exists := w.dir[dir]; !exists {
if err := w.watcher.Add(dir); err != nil {
return err

Check warning on line 70 in plugins/pkg/file/fs.go

View check run for this annotation

Codecov / codecov/patch

plugins/pkg/file/fs.go#L70

Added line #L70 was not covered by tests
Expand All @@ -79,7 +81,7 @@ func (w *Watcher) Start(onChanged func()) {
for {
select {
case event := <-w.watcher.Events:
if event.Op&fsnotify.Chmod == fsnotify.Chmod {
if event.Op.Has(fsnotify.Chmod) {
continue

Check warning on line 85 in plugins/pkg/file/fs.go

View check run for this annotation

Codecov / codecov/patch

plugins/pkg/file/fs.go#L85

Added line #L85 was not covered by tests
}
absPath, err := filepath.Abs(event.Name)
Expand Down

0 comments on commit b81b325

Please sign in to comment.