From dff708dfcb240b17713f865f259482e90e850587 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 16 Feb 2023 17:51:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4jar=E5=8C=85=E8=BF=98?= =?UTF-8?q?=E8=83=BD=E5=BC=95=E7=94=A8=E5=88=B0jar=E5=8C=85=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1023186 --user=王孝刚 【接口测试】文件管理中删除jar包后,还能引用到jar包的内容 https://www.tapd.cn/55049933/s/1336737 --- .../api/jmeter/NewDriverManager.java | 2 +- .../io/metersphere/utils/JarConfigUtils.java | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java index 3fe4b20afb..03673d72ad 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/NewDriverManager.java @@ -63,8 +63,8 @@ public class NewDriverManager { FileMetadataService fileMetadataService = CommonBeanFactory.getBean(FileMetadataService.class); map.forEach((key, value) -> { + loaderProjectIds.add(key); if (CollectionUtils.isNotEmpty(value)) { - loaderProjectIds.add(key); //历史数据 value.stream().distinct().filter(s -> s.isHasFile()).forEach(s -> { //获取文件内容 diff --git a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java index 24ec44261d..9e80dadd19 100644 --- a/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java +++ b/framework/sdk-parent/jmeter/src/main/java/io/metersphere/utils/JarConfigUtils.java @@ -35,13 +35,16 @@ public class JarConfigUtils { .stream() .map(ProjectJarConfig::getId) .collect(Collectors.toList()).contains(nodeFile)).collect(Collectors.toList()); - expiredJar.forEach(jar - -> deleteDir(StringUtils.join( - localPath, - File.separator, - item, - File.separator, - jar))); + if (CollectionUtils.isNotEmpty(expiredJar)) { + expiredJar.forEach(jar + -> deleteDir(StringUtils.join( + localPath, + File.separator, + item, + File.separator, + jar))); + jarConfigsMap.put(item, new ArrayList<>()); + } projectJarConfigs.forEach(projectJarConfig -> { if (CollectionUtils.isNotEmpty(nodeFiles)) { nodeFiles.forEach(refId -> { @@ -59,15 +62,18 @@ public class JarConfigUtils { } }); } else { + //本地完全没有jar包 需要下载 jarConfigs.add(projectJarConfig); } } }); } else { - //本地没有文件,需要从服务器下载 + //项目级别的目录都不存在,需要从服务器下载 jarConfigs.add(projectJarConfig); } - jarConfigsMap.put(item, jarConfigs); + if (CollectionUtils.isNotEmpty(jarConfigs)) { + jarConfigsMap.put(item, jarConfigs); + } }); } });