(normalizedPath string, now time.Time)
| 170 | } |
| 171 | |
| 172 | func (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 | } |
no outgoing calls