Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

707 B
Raw Blame
import { existsSync, lstatSync, readdirSync } from 'node:fs';
import { join } from 'node:path';

export function treeSize(root) {
  let total = 0;
  for (const entry of readdirSync(root, { withFileTypes: true })) {
    const path = join(root, entry.name);
    const stat = lstatSync(path);
    if (stat.isSymbolicLink()) {
      if (!existsSync(path)) {
        throw new Error(`Desktop package contains a broken symbolic link: ${path}`);
      }
      // Archives store the link target path, not another copy of its contents.
      total += stat.size;
    } else if (stat.isDirectory()) {
      total += treeSize(path);
    } else if (stat.isFile()) {
      total += stat.size;
    }
  }
  return total;
}