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.
This commit is contained in:
手瓜一十雪
2026-02-22 13:33:06 +08:00
parent 896e1c209a
commit 77bdcfd249

View File

@@ -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();