MCPcopy
hub / github.com/codeaashu/claude-code / cleanupOldPastes

Function cleanupOldPastes

src/utils/pasteStore.ts:76–104  ·  view source on GitHub ↗
(cutoffDate: Date)

Source from the content-addressed store, hash-verified

74 * This is a simple time-based cleanup - removes files older than cutoffDate.
75 */
76export async function cleanupOldPastes(cutoffDate: Date): Promise<void> {
77 const pasteDir = getPasteStoreDir()
78
79 let files
80 try {
81 files = await readdir(pasteDir)
82 } catch {
83 // Directory doesn't exist or can't be read - nothing to clean up
84 return
85 }
86
87 const cutoffTime = cutoffDate.getTime()
88 for (const file of files) {
89 if (!file.endsWith('.txt')) {
90 continue
91 }
92
93 const filePath = join(pasteDir, file)
94 try {
95 const stats = await stat(filePath)
96 if (stats.mtimeMs < cutoffTime) {
97 await unlink(filePath)
98 logForDebugging(`Cleaned up old paste: ${filePath}`)
99 }
100 } catch {
101 // Ignore errors for individual files
102 }
103 }
104}
105

Callers 1

Calls 5

getPasteStoreDirFunction · 0.85
readdirFunction · 0.85
statFunction · 0.85
unlinkFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected