MCPcopy Create free account
hub / github.com/Noumena-Network/code / cleanupOldMessageFilesInBackground

Function cleanupOldMessageFilesInBackground

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

Source from the content-addressed store, hash-verified

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

Callers 1

runVerySlowOpsFunction · 0.85

Calls 15

getSettingsWithAllErrorsFunction · 0.85
rawSettingsContainsKeyFunction · 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