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 { Router } from 'express';
import multer from 'multer'; // import multer from 'multer';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import os from 'os'; import os from 'os';
@@ -12,7 +12,7 @@ import {
RegisterPluginManagerHandler, RegisterPluginManagerHandler,
PluginConfigSSEHandler, PluginConfigSSEHandler,
PluginConfigChangeHandler, PluginConfigChangeHandler,
ImportLocalPluginHandler, // ImportLocalPluginHandler,
GetPluginIconHandler GetPluginIconHandler
} from '@/napcat-webui-backend/src/api/Plugin'; } from '@/napcat-webui-backend/src/api/Plugin';
import { import {
@@ -31,32 +31,32 @@ if (!fs.existsSync(uploadDir)) {
fs.mkdirSync(uploadDir, { recursive: true }); fs.mkdirSync(uploadDir, { recursive: true });
} }
const storage = multer.diskStorage({ // const storage = multer.diskStorage({
destination: (_req, _file, cb) => { // destination: (_req, _file, cb) => {
cb(null, uploadDir); // cb(null, uploadDir);
}, // },
filename: (_req, file, cb) => { // filename: (_req, file, cb) => {
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9); // const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
cb(null, uniqueSuffix + '-' + file.originalname); // cb(null, uniqueSuffix + '-' + file.originalname);
} // }
}); // });
const upload = multer({ // const upload = multer({
storage, // storage,
limits: { // limits: {
fileSize: 50 * 1024 * 1024, // 50MB 限制 // fileSize: 50 * 1024 * 1024, // 50MB 限制
}, // },
fileFilter: (_req, file, cb) => { // fileFilter: (_req, file, cb) => {
// 只允许 .zip 文件 // // 只允许 .zip 文件
if (file.mimetype === 'application/zip' || // if (file.mimetype === 'application/zip' ||
file.mimetype === 'application/x-zip-compressed' || // file.mimetype === 'application/x-zip-compressed' ||
file.originalname.endsWith('.zip')) { // file.originalname.endsWith('.zip')) {
cb(null, true); // cb(null, true);
} else { // } else {
cb(new Error('Only .zip files are allowed')); // cb(new Error('Only .zip files are allowed'));
} // }
} // }
}); // });
const router: Router = Router(); const router: Router = Router();