| 40 | const configPath = path.join(dataDir, "config.json"); |
| 41 | let dbPromise: Promise<Low<BananaConfig>> | null = null; |
| 42 | |
| 43 | const formatBytes = (bytes: number): string => { |
| 44 | if (bytes >= 1024 * 1024) { |
| 45 | const mb = bytes / (1024 * 1024); |
| 46 | return `${mb.toFixed(mb >= 10 ? 0 : 1).replace(/\.0$/, "")}MB`; |
| 47 | } |
| 48 | if (bytes >= 1024) { |
| 49 | const kb = bytes / 1024; |
| 50 | return `${kb.toFixed(kb >= 10 ? 0 : 1).replace(/\.0$/, "")}KB`; |
| 51 | } |
| 52 | return `${bytes}B`; |
| 53 | }; |
| 54 | |
| 55 | function estimateMediaSizeBytes(message: Api.Message): number { |
| 56 | const doc = (message as any).document; |