INNER CODE UNIT · TypeScript
calculateDirSize
pranshuchittora/simvyn · packages/server/src/app.ts:234
async function calculateDirSize(dirPath: string): Promise<number> {
let total = 0;
try {
const entries = await readdir(dirPath, { withFileTypes: true });
for (const entry of entries) {
const entryPath = join(dirPath, entry.name);
if (entry.isDirectory()) {
total += await calculateDirSize(entryPath);
} else {
const s = await stat(entryPath);
total += s.size;
}
}
} catch {}
return total;
}
fastify.get("/api/tool-settings/storage", async () => {