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

Function deletePluginCache

src/utils/plugins/installedPluginsManager.ts:975–1006  ·  view source on GitHub ↗
(installPath: string)

Source from the content-addressed store, hash-verified

973export { getGitCommitSha }
974
975export function deletePluginCache(installPath: string): void {
976 const fs = getFsImplementation()
977
978 try {
979 fs.rmSync(installPath, { recursive: true, force: true })
980 logForDebugging(`Deleted plugin cache at ${installPath}`)
981
982 // Clean up empty parent plugin directory (cache/{marketplace}/{plugin})
983 // Versioned paths have structure: cache/{marketplace}/{plugin}/{version}
984 const cachePath = getPluginCachePath()
985 if (installPath.includes('/cache/') && installPath.startsWith(cachePath)) {
986 const pluginDir = dirname(installPath) // e.g., cache/{marketplace}/{plugin}
987 if (pluginDir !== cachePath && pluginDir.startsWith(cachePath)) {
988 try {
989 const contents = fs.readdirSync(pluginDir)
990 if (contents.length === 0) {
991 fs.rmdirSync(pluginDir)
992 logForDebugging(`Deleted empty plugin directory at ${pluginDir}`)
993 }
994 } catch {
995 // Parent dir doesn't exist or isn't readable — skip cleanup
996 }
997 }
998 }
999 } catch (error) {
1000 const errorMsg = errorMessage(error)
1001 logError(toError(error))
1002 throw new Error(
1003 `Failed to delete plugin cache at ${installPath}: ${errorMsg}`,
1004 )
1005 }
1006}
1007
1008/**
1009 * Get the git commit SHA from a git repository directory

Callers

nothing calls this directly

Calls 6

getFsImplementationFunction · 0.85
getPluginCachePathFunction · 0.85
logForDebuggingFunction · 0.50
errorMessageFunction · 0.50
logErrorFunction · 0.50
toErrorFunction · 0.50

Tested by

no test coverage detected