From aa712d30ca5c4e9dcbebb1eb55f995613b95f638 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 17 Aug 2022 18:45:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E5=85=BC=E5=AE=B9=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/metadata/service/FileMetadataService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java b/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java index b2ee693f2d..b46bda8f0d 100644 --- a/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java +++ b/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java @@ -253,9 +253,11 @@ public class FileMetadataService { if (fileMetadataMapper.selectByPrimaryKey(fileMetadata.getId()) != null) { fileMetadata.setUpdateTime(System.currentTimeMillis()); fileMetadata.setUpdateUser(SessionUtils.getUserId()); - fileMetadata.setPath(FileUtils.getFilePath(fileMetadata)); + // 历史数据的路径不做更新 + if (StringUtils.isNotEmpty(fileMetadata.getStorage()) && StringUtils.isEmpty(fileMetadata.getResourceType())) { + fileMetadata.setPath(FileUtils.getFilePath(fileMetadata)); + } fileMetadataMapper.updateByPrimaryKeySelective(fileMetadata); - } } @@ -343,6 +345,7 @@ public class FileMetadataService { FileMetadataExample fileMetadata = new FileMetadataExample(); fileMetadata.createCriteria().andProjectIdIn(projectIds).andLoadJarEqualTo(true); List files = fileMetadataMapper.selectByExample(fileMetadata); + files = files.stream().filter(s -> StringUtils.isNotEmpty(s.getPath())).collect(Collectors.toList()); return files.stream().map(FileMetadata::getPath).collect(Collectors.toList()); } return new LinkedList<>();