MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / pruneBackups

Function pruneBackups

scripts/restore-drill.js:74–93  ·  view source on GitHub ↗
(backupDir, retentionDays)

Source from the content-addressed store, hash-verified

72}
73
74async function pruneBackups(backupDir, retentionDays) {
75 if (!Number.isFinite(retentionDays) || retentionDays <= 0) {
76 return;
77 }
78
79 const entries = await readdir(backupDir, { withFileTypes: true });
80 const cutoff = Date.now() - (retentionDays * 24 * 60 * 60 * 1000);
81
82 for (const entry of entries) {
83 if (!entry.isFile() || !entry.name.endsWith('.dump')) {
84 continue;
85 }
86
87 const fullPath = path.join(backupDir, entry.name);
88 const fileStats = await stat(fullPath);
89 if (fileStats.mtimeMs < cutoff) {
90 await unlink(fullPath);
91 }
92 }
93}
94
95function buildDatabaseUrlWithName(databaseUrl, databaseName) {
96 const parsed = new URL(databaseUrl);

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected