From d10798a9f6938b35bf478810d6645843fc82e110 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 7 Dec 2022 22:48:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E4=BE=8B=E9=99=84=E4=BB=B6=E8=A2=AB?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=88=A0=E9=99=A4=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/definition/ApiTestCaseService.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java index f9e9bf0528..09b1c6cdcb 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java @@ -333,10 +333,14 @@ public class ApiTestCaseService { extApiDefinitionExecResultMapper.deleteByResourceId(testId); apiTestCaseMapper.deleteByPrimaryKey(testId); esbApiParamService.deleteByResourceId(testId); - deleteBodyFiles(testId); // 删除附件关系 extFileAssociationService.deleteByResourceId(testId); deleteFollows(testId); + ApiTestCase apiTestCase = apiTestCaseMapper.selectByPrimaryKey(testId); + if (apiTestCase != null) { + String filePath = StringUtils.join(BODY_FILE_DIR, File.separator, apiTestCase.getId()); + FileUtil.deleteContents(new File(filePath)); + } } private void deleteFollows(String testId) { @@ -362,14 +366,6 @@ public class ApiTestCaseService { } } - public void deleteBodyFiles(String testId) { - File file = new File(BODY_FILE_DIR + "/" + testId); - FileUtil.deleteContents(file); - if (file.exists()) { - file.delete(); - } - } - public void checkNameExist(SaveApiTestCaseRequest request) { if (hasSameCase(request)) { MSException.throwException(Translator.get("case_name_is_already_exist") + ": " + request.getName());