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

Function cleanupOldMessageFilesInBackground

src/utils/cleanup.ts:575–602  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

573}
574
575export async function cleanupOldMessageFilesInBackground(): Promise<void> {
576 // If settings have validation errors but the user explicitly set cleanupPeriodDays,
577 // skip cleanup entirely rather than falling back to the default (30 days).
578 // This prevents accidentally deleting files when the user intended a different retention period.
579 const { errors } = getSettingsWithAllErrors()
580 if (errors.length > 0 && rawSettingsContainsKey('cleanupPeriodDays')) {
581 logForDebugging(
582 'Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.',
583 )
584 return
585 }
586
587 await cleanupOldMessageFiles()
588 await cleanupOldSessionFiles()
589 await cleanupOldPlanFiles()
590 await cleanupOldFileHistoryBackups()
591 await cleanupOldSessionEnvDirs()
592 await cleanupOldDebugLogs()
593 await cleanupOldImageCaches()
594 await cleanupOldPastes(getCutoffDate())
595 const removedWorktrees = await cleanupStaleAgentWorktrees(getCutoffDate())
596 if (removedWorktrees > 0) {
597 logEvent('tengu_worktree_cleanup', { removed: removedWorktrees })
598 }
599 if (process.env.USER_TYPE === 'ant') {
600 await cleanupNpmCacheForAnthropicPackages()
601 }
602}
603

Callers 1

runVerySlowOpsFunction · 0.85

Calls 15

getSettingsWithAllErrorsFunction · 0.85
rawSettingsContainsKeyFunction · 0.85
logForDebuggingFunction · 0.85
cleanupOldMessageFilesFunction · 0.85
cleanupOldSessionFilesFunction · 0.85
cleanupOldPlanFilesFunction · 0.85
cleanupOldSessionEnvDirsFunction · 0.85
cleanupOldDebugLogsFunction · 0.85
cleanupOldImageCachesFunction · 0.85
cleanupOldPastesFunction · 0.85
getCutoffDateFunction · 0.85

Tested by

no test coverage detected