fix(data): 清理临时目录时跳过子目录,并回收 multer 残片

transfers/ 下面还套着 multer 的 uploads/ 子目录;原来只清理一层,目录本身会被当成过期文件去 unlink(失败但刷日志),
而 uploads/ 里因体积超限被丢弃的残片又永远不会被清。现在只删普通文件,并两处都清。
This commit is contained in:
Drsakura
2026-10-23 13:52:14 +08:00
parent 5acfbcea7d
commit ee7550c890
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -121,6 +121,8 @@ router.post('/import/preview', guard, upload.single('file'), async (req, res) =>
fs.renameSync(req.file.path, target)
/* 顺手清掉 24 小时前的旧包,避免上传目录无限增长(本次刚移入的 mtime 是现在,不会被删) */
transfer.cleanupUploads(TRANSFER_DIR)
/* multer 落盘后因体积/字段错误被丢弃的残片留在 uploads/,一并清 */
transfer.cleanupUploads(UPLOAD_DIR)
const categories = parseCategories(req.body?.categories)
const preview = await transfer.previewImport(db, target, {