topfans/frontend/utils/handlers/sandboxTmpHandler.js
2026-07-29 16:03:33 +08:00

27 lines
966 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// frontend/utils/handlers/sandboxTmpHandler.js
// 沙盒临时文件 handler简单型
// reviewer P0 修正:不再依赖私有 ioPath 内部函数,全部走 ioPath 导出 API
import { scanSandboxTmpFiles, countSandboxTmpFiles, clearAllSandboxTmpFiles } from '@/utils/ioPath'
export default {
id: 'sandbox-tmp',
label: '临时文件',
description: '上传/分享过程产生的临时文件',
warning: false,
async computeSize() {
const [bytes, count] = await Promise.all([
scanSandboxTmpFiles(),
countSandboxTmpFiles(), // 真实文件数reviewer P0 修正)
])
return { sizeBytes: bytes, keyCount: count }
},
async clean() {
const [before, beforeCount] = await Promise.all([
scanSandboxTmpFiles(),
countSandboxTmpFiles(),
])
await clearAllSandboxTmpFiles()
const after = await scanSandboxTmpFiles()
return { freedBytes: Math.max(0, before - after), keyCount: beforeCount }
},
}