MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / getDirectorySizeFallback

Function getDirectorySizeFallback

lib/models/files.ts:780–796  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

778}
779
780async function getDirectorySizeFallback(path: string): Promise<number> {
781 let totalSize = 0;
782 try {
783 for await (const entry of Deno.readDir(path)) {
784 const entryPath = join(path, entry.name);
785 const stat = await Deno.lstat(entryPath);
786 if (stat.isDirectory) {
787 totalSize += await getDirectorySizeFallback(entryPath);
788 } else {
789 totalSize += stat.size;
790 }
791 }
792 } catch (error) {
793 console.error(error);
794 }
795 return totalSize;
796}
797
798// NOTE: We're using `-h` (human readable) and parsing the output because that's more stable than `-B 1B` across different systems for a reliable byte size.
799async function getDirectorySize(path: string): Promise<number> {

Callers 1

getDirectorySizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected