22 lines
888 B
JavaScript
22 lines
888 B
JavaScript
// frontend/utils/handlers/sandboxTmpHandler.js
|
||
// 沙盒临时文件 handler(简单型)
|
||
import { scanSandboxTmpFiles, clearAllSandboxTmpFiles } from '@/utils/ioPath'
|
||
|
||
export default {
|
||
id: 'sandbox-tmp',
|
||
label: '临时文件',
|
||
description: '上传/分享过程产生的临时文件',
|
||
warning: false,
|
||
async computeSize() {
|
||
// scanSandboxTmpFiles 一次返回 {sizeBytes, keyCount}(替代旧的 size+count 双遍历)
|
||
return await scanSandboxTmpFiles()
|
||
},
|
||
async clean() {
|
||
// 边量边删:clearAllSandboxTmpFiles 内部对每个 tmp/ 目录先 _statDir 拿 before
|
||
// 字节/计数,再 removeRecursively,返回 { freedBytes, keyCount, ... }
|
||
// 调用方不再做 before/after 三次扫描,慢设备不再卡 4s 超时
|
||
const r = await clearAllSandboxTmpFiles()
|
||
return { freedBytes: r.freedBytes || 0, keyCount: r.keyCount || 0 }
|
||
},
|
||
}
|