From 77bdcfd249aa85b5d3e34c9cc8f78041efa7e3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 22 Feb 2026 13:33:06 +0800 Subject: [PATCH] Disable local plugin import and upload handling Commented out ImportLocalPluginHandler import and the multer upload configuration (50MB limit and .zip file filter). Temporarily disables local plugin .zip uploads, likely for debugging or while refactoring the upload/import flow; can be re-enabled when upload handling is restored. --- .../napcat-webui-backend/src/router/Plugin.ts | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/napcat-webui-backend/src/router/Plugin.ts b/packages/napcat-webui-backend/src/router/Plugin.ts index f4bbed6f..b4009736 100644 --- a/packages/napcat-webui-backend/src/router/Plugin.ts +++ b/packages/napcat-webui-backend/src/router/Plugin.ts @@ -1,5 +1,5 @@ import { Router } from 'express'; -import multer from 'multer'; +// import multer from 'multer'; import path from 'path'; import fs from 'fs'; import os from 'os'; @@ -12,7 +12,7 @@ import { RegisterPluginManagerHandler, PluginConfigSSEHandler, PluginConfigChangeHandler, - ImportLocalPluginHandler, + // ImportLocalPluginHandler, GetPluginIconHandler } from '@/napcat-webui-backend/src/api/Plugin'; import { @@ -31,32 +31,32 @@ if (!fs.existsSync(uploadDir)) { fs.mkdirSync(uploadDir, { recursive: true }); } -const storage = multer.diskStorage({ - destination: (_req, _file, cb) => { - cb(null, uploadDir); - }, - filename: (_req, file, cb) => { - const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9); - cb(null, uniqueSuffix + '-' + file.originalname); - } -}); +// const storage = multer.diskStorage({ +// destination: (_req, _file, cb) => { +// cb(null, uploadDir); +// }, +// filename: (_req, file, cb) => { +// const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9); +// cb(null, uniqueSuffix + '-' + file.originalname); +// } +// }); -const upload = multer({ - storage, - limits: { - fileSize: 50 * 1024 * 1024, // 50MB 限制 - }, - fileFilter: (_req, file, cb) => { - // 只允许 .zip 文件 - if (file.mimetype === 'application/zip' || - file.mimetype === 'application/x-zip-compressed' || - file.originalname.endsWith('.zip')) { - cb(null, true); - } else { - cb(new Error('Only .zip files are allowed')); - } - } -}); +// const upload = multer({ +// storage, +// limits: { +// fileSize: 50 * 1024 * 1024, // 50MB 限制 +// }, +// fileFilter: (_req, file, cb) => { +// // 只允许 .zip 文件 +// if (file.mimetype === 'application/zip' || +// file.mimetype === 'application/x-zip-compressed' || +// file.originalname.endsWith('.zip')) { +// cb(null, true); +// } else { +// cb(new Error('Only .zip files are allowed')); +// } +// } +// }); const router: Router = Router();