From 9d0616f89f8fdc15ca0fdb31a69becfb7ee35f98 Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 15 Jun 2021 09:50:36 +0800 Subject: [PATCH] =?UTF-8?q?fps-import:=20=E4=BF=AE=E5=A4=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=BA=E7=A9=BA=E5=AF=BC=E8=87=B4=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fps-importer/handler.ts | 20 ++++++++++++-------- packages/fps-importer/package.json | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/fps-importer/handler.ts b/packages/fps-importer/handler.ts index 09979e8a..6a28fb03 100644 --- a/packages/fps-importer/handler.ts +++ b/packages/fps-importer/handler.ts @@ -70,14 +70,18 @@ class FpsProblemImportHandler extends Handler { await problem.addTestdata(domainId, pid, 'config.yaml', Buffer.from(`time: ${config.time}\nmemory: ${config.memory}`)); if (p.test_output) { for (let i = 0; i < p.test_input.length; i++) { - await problem.addTestdata( - domainId, pid, `${i + 1}.in`, - Buffer.from(p.test_input[i]._ || p.test_input[i]), - ); - await problem.addTestdata( - domainId, pid, `${i + 1}.out`, - Buffer.from(p.test_output[i]._ || p.test_output[i]), - ); + const input = typeof p.test_input[i]?._ === 'string' + ? p.test_input[i]?._ + : typeof p.test_input[i] === 'string' + ? p.test_input[i] + : ''; + const output = typeof p.test_output[i]?._ === 'string' + ? p.test_output[i]?._ + : typeof p.test_output[i] === 'string' + ? p.test_output[i] + : ''; + await problem.addTestdata(domainId, pid, `${i + 1}.in`, Buffer.from(input)); + await problem.addTestdata(domainId, pid, `${i + 1}.out`, Buffer.from(output)); } } else if (p.test_input) { for (let i = 0; i < p.test_input.length / 2; i++) { diff --git a/packages/fps-importer/package.json b/packages/fps-importer/package.json index ad12f198..a5440b69 100644 --- a/packages/fps-importer/package.json +++ b/packages/fps-importer/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/fps-importer", - "version": "1.2.1", + "version": "1.2.2", "description": "Import FPS problems", "main": "package.json", "repository": "https://github.com/hydro-dev/Hydro.git",