MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / shouldDebounceRemove

Method shouldDebounceRemove

internal/watcher/events.go:172–197  ·  view source on GitHub ↗
(normalizedPath string, now time.Time)

Source from the content-addressed store, hash-verified

170}
171
172func (w *Watcher) shouldDebounceRemove(normalizedPath string, now time.Time) bool {
173 if normalizedPath == "" {
174 return false
175 }
176 w.clientsMutex.Lock()
177 if w.lastRemoveTimes == nil {
178 w.lastRemoveTimes = make(map[string]time.Time)
179 }
180 if last, ok := w.lastRemoveTimes[normalizedPath]; ok {
181 if now.Sub(last) < authRemoveDebounceWindow {
182 w.clientsMutex.Unlock()
183 return true
184 }
185 }
186 w.lastRemoveTimes[normalizedPath] = now
187 if len(w.lastRemoveTimes) > 128 {
188 cutoff := now.Add(-2 * authRemoveDebounceWindow)
189 for p, t := range w.lastRemoveTimes {
190 if t.Before(cutoff) {
191 delete(w.lastRemoveTimes, p)
192 }
193 }
194 }
195 w.clientsMutex.Unlock()
196 return false
197}

Callers 3

TestShouldDebounceRemoveFunction · 0.95
handleEventMethod · 0.95

Calls

no outgoing calls

Tested by 2

TestShouldDebounceRemoveFunction · 0.76