27 lines
966 B
JavaScript
27 lines
966 B
JavaScript
// 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 }
|
||
},
|
||
} |