MCPcopy
hub / github.com/colbymchenry/codegraph / getDirectorySize

Function getDirectorySize

src/directory.ts:532–563  ·  view source on GitHub ↗
(projectRoot: string)

Source from the content-addressed store, hash-verified

530 * Get the total size of the .codegraph directory in bytes
531 */
532export function getDirectorySize(projectRoot: string): number {
533 const codegraphDir = getCodeGraphDir(projectRoot);
534
535 if (!fs.existsSync(codegraphDir)) {
536 return 0;
537 }
538
539 let totalSize = 0;
540
541 function walkDir(dir: string): void {
542 const entries = fs.readdirSync(dir, { withFileTypes: true });
543
544 for (const entry of entries) {
545 // Skip symlinks to prevent following links outside .codegraph
546 if (entry.isSymbolicLink()) {
547 continue;
548 }
549
550 const fullPath = path.join(dir, entry.name);
551
552 if (entry.isDirectory()) {
553 walkDir(fullPath);
554 } else {
555 const stats = fs.statSync(fullPath);
556 totalSize += stats.size;
557 }
558 }
559 }
560
561 walkDir(codegraphDir);
562 return totalSize;
563}
564
565/**
566 * Ensure a subdirectory exists within .codegraph

Callers

nothing calls this directly

Calls 2

getCodeGraphDirFunction · 0.85
walkDirFunction · 0.85

Tested by

no test coverage detected