MCPcopy
hub / github.com/desktop/desktop / pruneDirectory

Function pruneDirectory

app/src/main-process/desktop-file-transport.ts:89–100  ·  view source on GitHub ↗
(p: string)

Source from the content-addressed store, hash-verified

87 .catch(error('readdir'))
88
89const pruneDirectory = async (p: string) => {
90 const all = await getLogFilesIn(p)
91
92 if (all && all.length > MaxRetainedLogFiles) {
93 const end = all.length - MaxRetainedLogFiles + 1
94 const old = all.sort().slice(0, end)
95
96 for (const f of old) {
97 await unlink(join(p, f.name)).catch(error('unlink'))
98 }
99 }
100}

Callers 1

logMethod · 0.85

Calls 2

getLogFilesInFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected