* Handle a file being deleted. Uses a grace period to absorb delete-and-recreate * patterns (e.g. auto-updater, another session starting up). If the file is * recreated within the grace period (detected via 'add' or 'change' event), * the deletion is cancelled and treated as a normal change inste
(path: string)
| 328 | * the deletion is cancelled and treated as a normal change instead. |
| 329 | */ |
| 330 | function handleDelete(path: string): void { |
| 331 | const source = getSourceForPath(path) |
| 332 | if (!source) return |
| 333 | |
| 334 | logForDebugging(`Detected deletion of ${path}`) |
| 335 | |
| 336 | // If there's already a pending deletion for this path, let it run |
| 337 | if (pendingDeletions.has(path)) return |
| 338 | |
| 339 | const timer = setTimeout( |
| 340 | (p, src) => { |
| 341 | pendingDeletions.delete(p) |
| 342 | |
| 343 | // Fire ConfigChange hook first — if blocked, skip applying the deletion |
| 344 | void executeConfigChangeHooks( |
| 345 | settingSourceToConfigChangeSource(src), |
| 346 | p, |
| 347 | ).then(results => { |
| 348 | if (hasBlockingResult(results)) { |
| 349 | logForDebugging(`ConfigChange hook blocked deletion of ${p}`) |
| 350 | return |
| 351 | } |
| 352 | fanOut(src) |
| 353 | }) |
| 354 | }, |
| 355 | testOverrides?.deletionGrace ?? DELETION_GRACE_MS, |
| 356 | path, |
| 357 | source, |
| 358 | ) |
| 359 | pendingDeletions.set(path, timer) |
| 360 | } |
| 361 | |
| 362 | function getSourceForPath(path: string): SettingSource | undefined { |
| 363 | // Normalize path because chokidar uses forward slashes on Windows |
nothing calls this directly
no test coverage detected