From 308b568931ec7ec8efde1df261b64303187f9bef Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Fri, 20 Sep 2024 10:49:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=E6=96=87=E4=BB=B6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bug/controller/BugAttachmentControllerTests.java | 2 +- .../service/FunctionalCaseAttachmentService.java | 7 ++----- .../metersphere/project/service/FileMetadataService.java | 3 --- .../io/metersphere/system/service/CommonFileService.java | 3 --- .../io/metersphere/system/service/SimpleUserService.java | 5 ----- 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java index 397a5908ac..a668220c8f 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java @@ -56,7 +56,7 @@ public class BugAttachmentControllerTests extends BaseTest { @Order(0) void testUploadMdFile() throws Exception { MockMultipartFile fileTooLarge = new MockMultipartFile("file", "test.txt", MediaType.APPLICATION_OCTET_STREAM_VALUE, new byte[50 * 1024 * 1024 + 1]); - this.requestUploadFile(BUG_ATTACHMENT_UPLOAD_MD, fileTooLarge).andExpect(status().is5xxServerError()); + this.requestUploadFile(BUG_ATTACHMENT_UPLOAD_MD, fileTooLarge).andExpect(status().is2xxSuccessful()); MockMultipartFile fileWithNoName = new MockMultipartFile("file", "", MediaType.APPLICATION_OCTET_STREAM_VALUE, "aa".getBytes()); this.requestUploadFile(BUG_ATTACHMENT_UPLOAD_MD, fileWithNoName).andExpect(status().is5xxServerError()); // Mock minio save file exception diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java index fbd8571ccd..92cf8767f8 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java @@ -15,8 +15,6 @@ import io.metersphere.project.domain.FileAssociation; import io.metersphere.project.dto.filemanagement.FileInfo; import io.metersphere.project.dto.filemanagement.FileLogRecord; import io.metersphere.project.service.FileAssociationService; -import io.metersphere.system.service.CommonFileService; -import io.metersphere.system.service.FileService; import io.metersphere.sdk.constants.DefaultRepositoryDir; import io.metersphere.sdk.constants.StorageType; import io.metersphere.sdk.exception.MSException; @@ -29,6 +27,8 @@ import io.metersphere.system.domain.User; import io.metersphere.system.domain.UserExample; import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.mapper.UserMapper; +import io.metersphere.system.service.CommonFileService; +import io.metersphere.system.service.FileService; import io.metersphere.system.uid.IDGenerator; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; @@ -109,9 +109,6 @@ public class FunctionalCaseAttachmentService { fileRequest.setFileName(file.getOriginalFilename()); fileRequest.setFolder(DefaultRepositoryDir.getFunctionalCaseDir(projectId, caseId) + "/" + fileId); fileRequest.setStorage(StorageType.MINIO.name()); - if (file.getSize() > maxFileSize.toBytes()) { - throw new MSException(Translator.get("file.size.is.too.large")); - } try { fileService.upload(file, fileRequest); } catch (Exception e) { 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 31fd8375dd..240da2cb1d 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 @@ -150,9 +150,6 @@ public class FileMetadataService { } public FileMetadata genFileMetadata(String fileSpecifyName, String filePath, String storage, long size, boolean enable, String projectId, String moduleId, String operator) { - if (size > maxFileSize.toBytes()) { - throw new MSException(Translator.get("file.size.is.too.large")); - } FileMetadata fileMetadata = new FileMetadata(); this.parseAndSetFileNameType(filePath, fileMetadata); //如果开启了开关,检查是否是jar文件 diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonFileService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonFileService.java index f5c3469438..f42dfc2ebd 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonFileService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonFileService.java @@ -44,9 +44,6 @@ public class CommonFileService { */ public String uploadTempImgFile(MultipartFile file) { String fileName = StringUtils.trim(file.getOriginalFilename()); - if (file.getSize() > maxFileSize.toBytes()) { - throw new MSException(Translator.get("file.size.is.too.large")); - } if (StringUtils.isBlank(fileName)) { throw new MSException(Translator.get("file.name.cannot.be.empty")); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java index 92ba6863f0..da4da0cbbc 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SimpleUserService.java @@ -255,11 +255,6 @@ public class SimpleUserService { } public UserImportResponse importByExcel(MultipartFile excelFile, String source, String sessionId) { - - if (excelFile.getSize() > maxImportFileSize.toBytes()) { - throw new MSException(Translator.get("file.size.is.too.large")); - } - UserImportResponse importResponse = new UserImportResponse(); ExcelParseDTO excelParseDTO = new ExcelParseDTO<>(); try {