From 1c18668bad64180332479d13fd3b5507a7cddfe5 Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 22 May 2025 00:09:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/script.ts | 5 ++++- back/config/util.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/back/api/script.ts b/back/api/script.ts index e304b768..1bf85565 100644 --- a/back/api/script.ts +++ b/back/api/script.ts @@ -232,7 +232,7 @@ export default (app: Router) => { celebrate({ body: Joi.object({ filename: Joi.string().required(), - path: Joi.string().allow(''), + path: Joi.string().optional().allow(''), }), }), async (req: Request, res: Response, next: NextFunction) => { @@ -241,6 +241,9 @@ export default (app: Router) => { filename: string; path: string; }; + if (!path) { + path = ''; + } const scriptService = Container.get(ScriptService); const filePath = scriptService.checkFilePath(path, filename); if (!filePath) { diff --git a/back/config/util.ts b/back/config/util.ts index 96070009..e6a77219 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -517,7 +517,7 @@ export async function setSystemTimezone(timezone: string): Promise { export function getGetCommand(type: DependenceTypes, name: string): string { const baseCommands = { [DependenceTypes.nodejs]: `pnpm ls -g | grep "${name}" | head -1`, - [DependenceTypes.python3]: `python3 -c "import importlib;pkg=importlib.import_module('${name}');print(getattr(pkg, '__version__', 'version not found'))"`, + [DependenceTypes.python3]: `python3 -c "import importlib;pkg=importlib.import_module('${name}');print(getattr(pkg, '__version__', 'inner package'))"`, [DependenceTypes.linux]: `apk info -es ${name}`, };