fix: remove undici dependency and clean up ProxyManager code (#6020)

This commit is contained in:
MyPrototypeWhat
2025-05-15 22:09:53 +08:00
committed by GitHub
parent cb64646cb9
commit f3b9b3c84c
6 changed files with 48 additions and 45 deletions
+18
View File
@@ -1,4 +1,5 @@
import fs from 'node:fs'
import fsAsync from 'node:fs/promises'
import path from 'node:path'
import { app } from 'electron'
@@ -52,3 +53,20 @@ export function makeSureDirExists(dir: string) {
fs.mkdirSync(dir, { recursive: true })
}
}
export async function calculateDirectorySize(directoryPath: string): Promise<number> {
let totalSize = 0
const items = await fsAsync.readdir(directoryPath)
for (const item of items) {
const itemPath = path.join(directoryPath, item)
const stats = await fsAsync.stat(itemPath)
if (stats.isFile()) {
totalSize += stats.size
} else if (stats.isDirectory()) {
totalSize += await calculateDirectorySize(itemPath)
}
}
return totalSize
}