MCPcopy
hub / github.com/go-task/task / GetChan

Method GetChan

internal/fsnotifyext/fsnotify_dedup.go:25–51  ·  view source on GitHub ↗

GetChan returns a chan of deduplicated [fsnotify.Event]. [fsnotify.Chmod] operations will be skipped.

()

Source from the content-addressed store, hash-verified

23//
24// [fsnotify.Chmod] operations will be skipped.
25func (d *Deduper) GetChan() <-chan fsnotify.Event {
26 channel := make(chan fsnotify.Event)
27
28 go func() {
29 timers := make(map[string]*time.Timer)
30 for {
31 event, ok := <-d.w.Events
32 switch {
33 case !ok:
34 return
35 case event.Has(fsnotify.Chmod):
36 continue
37 }
38
39 timer, ok := timers[event.String()]
40 if !ok {
41 timer = time.AfterFunc(math.MaxInt64, func() { channel <- event })
42 timer.Stop()
43 timers[event.String()] = timer
44 }
45
46 timer.Reset(d.waitTime)
47 }
48 }()
49
50 return channel
51}

Callers 1

watchTasksMethod · 0.95

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected