diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 11ca445f91..425ed75e42 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -376,12 +376,7 @@ public class ApiAutomationService { } deleteUpdateBodyFile(scenario, beforeScenario); - if (CollectionUtils.isNotEmpty(request.getScenarioDefinition().getHashTree())) { - request.getScenarioDefinition().getHashTree().stream().forEach(hashTree -> { - //删除不需要的文件 - FileUtils.deleteBodyFiles(hashTree); - }); - } + scenario.setCreateUser(null); // 更新时不更新创建人 ApiScenarioExample example = new ApiScenarioExample(); example.createCriteria().andIdEqualTo(scenario.getId()).andVersionIdEqualTo(request.getVersionId()); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 55dadb7145..ab96f106a3 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -357,8 +357,7 @@ public class ApiDefinitionService { MockConfigService mockConfigService = CommonBeanFactory.getBean(MockConfigService.class); mockConfigService.updateMockReturnMsgByApi(returnModel); FileUtils.createBodyFiles(request.getRequest().getId(), bodyFiles); - //删除不需要的文件 - FileUtils.deleteBodyFiles(request.getRequest()); + return getById(returnModel.getId()); } diff --git a/backend/src/main/java/io/metersphere/commons/utils/FileUtils.java b/backend/src/main/java/io/metersphere/commons/utils/FileUtils.java index 872d7e36ac..c73159d68f 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/FileUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/FileUtils.java @@ -1,13 +1,9 @@ package io.metersphere.commons.utils; -import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy; -import io.metersphere.api.dto.scenario.Body; -import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.dto.scenario.request.BodyFile; import io.metersphere.base.domain.JarConfig; import io.metersphere.commons.exception.MSException; import io.metersphere.i18n.Translator; -import io.metersphere.plugin.core.MsTestElement; import io.metersphere.service.JarConfigService; import io.metersphere.utils.LoggerUtil; import org.apache.commons.collections.CollectionUtils; @@ -23,7 +19,6 @@ import org.springframework.web.multipart.MultipartFile; import java.io.*; import java.util.*; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -124,44 +119,7 @@ public class FileUtils { }); } } - - public static void deleteBodyFiles(MsTestElement request) { - if (StringUtils.isNotBlank(request.getId())) { - String path = BODY_FILE_DIR + File.separator + request.getId(); - File testDir = new File(path); - if (!testDir.exists()) { - return; - } - List files = new ArrayList<>(); - if (request != null && StringUtils.equalsIgnoreCase(request.getType(), HTTPSamplerProxy.class.getSimpleName())) { - MsHTTPSamplerProxy samplerProxy = (MsHTTPSamplerProxy) request; - Body body = samplerProxy.getBody(); - if (body != null && !CollectionUtils.isEmpty(body.getKvs())) { - body.getKvs().stream().filter(KeyValue::isFile).forEach(keyValue -> { - files.addAll(keyValue.getFiles().stream().map(BodyFile::getName).collect(Collectors.toList())); - }); - } - if (body != null && !CollectionUtils.isEmpty(body.getBinary())) { - body.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> { - files.addAll(keyValue.getFiles().stream().map(BodyFile::getName).collect(Collectors.toList())); - }); - } - } - - File[] optFilesName = testDir.listFiles(); - if (CollectionUtils.isNotEmpty(files)) { - for (File f : optFilesName) { - if (!files.contains(f.getName())) { - f.delete(); - } - } - } else { - FileUtil.deleteContents(testDir); - testDir.delete(); - } - } - } - + public static void copyBodyFiles(String sourceId, String targetId) { try { String sourcePath = BODY_FILE_DIR + "/" + sourceId; diff --git a/frontend/src/business/components/api/definition/components/assertion/ApiJsonpathSuggest.vue b/frontend/src/business/components/api/definition/components/assertion/ApiJsonpathSuggest.vue index 9a103d9e57..66743f46de 100644 --- a/frontend/src/business/components/api/definition/components/assertion/ApiJsonpathSuggest.vue +++ b/frontend/src/business/components/api/definition/components/assertion/ApiJsonpathSuggest.vue @@ -1,5 +1,6 @@