MCPcopy Index your code
hub / github.com/codeaashu/claude-code / handleDelete

Function handleDelete

src/utils/settings/changeDetector.ts:330–360  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

328 * the deletion is cancelled and treated as a normal change instead.
329 */
330function 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
362function getSourceForPath(path: string): SettingSource | undefined {
363 // Normalize path because chokidar uses forward slashes on Windows

Callers

nothing calls this directly

Calls 9

getSourceForPathFunction · 0.85
logForDebuggingFunction · 0.85
executeConfigChangeHooksFunction · 0.85
hasBlockingResultFunction · 0.85
fanOutFunction · 0.85
deleteMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected