From 17cde7389813b9769ef27aa66c70bb7f45015b34 Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Wed, 17 Apr 2024 18:14:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E4=B8=8B=E8=BD=BD=E6=97=B6=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E5=A2=9E=E5=8A=A0=E5=94=AF=E4=B8=80=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1039607 --user=宋天阳 https://www.tapd.cn/55049933/s/1500081 --- .../metersphere/project/service/FileMetadataService.java | 2 +- .../io/metersphere/project/utils/FileMetadataUtils.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java index eff8589d83..fdff50b10e 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java @@ -353,7 +353,7 @@ public class FileMetadataService { public void batchDownloadWithResponse(List fileMetadataList, HttpServletResponse response) { Map fileMap = new HashMap<>(); - fileMetadataList.forEach(fileMetadata -> fileMap.put(FileMetadataUtils.getFileName(fileMetadata), this.getTmpFile(fileMetadata))); + fileMetadataList.forEach(fileMetadata -> fileMap.put(FileMetadataUtils.getFileNameWithId(fileMetadata), this.getTmpFile(fileMetadata))); FileDownloadUtils.zipFilesWithResponse(fileMap, response); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java b/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java index 9c2cbf33b9..33e3fd9c32 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java @@ -34,6 +34,13 @@ public class FileMetadataUtils { return fileMetadata.getName() + "." + fileMetadata.getType(); } + public static String getFileNameWithId(FileMetadata fileMetadata) { + if (StringUtils.isBlank(fileMetadata.getType())) { + return fileMetadata.getName() + "_" + fileMetadata.getId(); + } + return fileMetadata.getName() + "_" + fileMetadata.getId() + "." + fileMetadata.getType(); + } + /** * 将空文件类型转换为unknown *