| 778 | } |
| 779 | |
| 780 | async 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. |
| 799 | async function getDirectorySize(path: string): Promise<number> { |