MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getPluginDataDirSize

Function getPluginDataDirSize

src/utils/plugins/pluginDirectories.ts:130–160  ·  view source on GitHub ↗
(
  pluginId: string,
)

Source from the content-addressed store, hash-verified

128 * Recursive walk — not hot-path (only on uninstall).
129 */
130export async function getPluginDataDirSize(
131 pluginId: string,
132): Promise<{ bytes: number; human: string } | null> {
133 const dir = pluginDataDirPath(pluginId)
134 let bytes = 0
135 const walk = async (p: string) => {
136 for (const entry of await readdir(p, { withFileTypes: true })) {
137 const full = join(p, entry.name)
138 if (entry.isDirectory()) {
139 await walk(full)
140 } else {
141 // Per-entry catch: a broken symlink makes stat() throw ENOENT.
142 // Without this, one broken link bubbles to the outer catch →
143 // returns null → dialog skipped → data silently deleted.
144 try {
145 bytes += (await stat(full)).size
146 } catch {
147 // Broken symlink / raced delete — skip this entry, keep walking
148 }
149 }
150 }
151 }
152 try {
153 await walk(dir)
154 } catch (e) {
155 if (isFsInaccessible(e)) return null
156 throw e
157 }
158 if (bytes === 0) return null
159 return { bytes, human: formatFileSize(bytes) }
160}
161
162/**
163 * Best-effort cleanup on last-scope uninstall. Failure is logged but does

Callers 1

handleSingleOperationFunction · 0.85

Calls 4

pluginDataDirPathFunction · 0.85
isFsInaccessibleFunction · 0.85
formatFileSizeFunction · 0.85
walkFunction · 0.70

Tested by

no test coverage detected