From b0398d2f9c3fb6959753a41ccf775cfdbc66660f Mon Sep 17 00:00:00 2001 From: uname <2986773479@qq.com> Date: Tue, 9 Dec 2025 18:29:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20k8s=E9=83=A8=E7=BD=B2=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E4=B8=8B=EF=BC=8Cbackend-python=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=8C=82=E8=BD=BD=E9=9C=80=E8=A6=81=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployment/helm/datamate/values.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/deployment/helm/datamate/values.yaml b/deployment/helm/datamate/values.yaml index 1657a0ab0..15ec76688 100644 --- a/deployment/helm/datamate/values.yaml +++ b/deployment/helm/datamate/values.yaml @@ -95,6 +95,24 @@ backend: - name: operator-volume mountPath: /operators +backend-python: + env: + - name: DB_PASSWORD + value: *dbPass + volumes: + - *datasetVolume + - *flowVolume + - *logVolume + volumeMounts: + - name: dataset-volume + mountPath: /dataset + - name: flow-volume + mountPath: /flow + - name: log-volume + mountPath: /var/log/datamate + - name: operator-volume + mountPath: /operators + frontend: service: type: NodePort From a69bed6bdc61b1d71dc9b3a26237b0be89eea8dc Mon Sep 17 00:00:00 2001 From: uname <2986773479@qq.com> Date: Tue, 9 Dec 2025 21:01:55 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=96=87=E4=BB=B6=E5=85=8D=E6=8B=B7=E8=B4=9D=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/openapi/specs/data-management.yaml | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/backend/openapi/specs/data-management.yaml b/backend/openapi/specs/data-management.yaml index 1aac250bb..b9d26fdb3 100644 --- a/backend/openapi/specs/data-management.yaml +++ b/backend/openapi/specs/data-management.yaml @@ -330,6 +330,35 @@ paths: type: string format: binary + /data-management/datasets/{datasetId}/files/upload/add: + post: + tags: [ DatasetFile ] + operationId: addFilesToDataset + summary: 添加文件到数据集(仅创建数据库记录) + description: 将指定源文件路径列表添加到数据集,仅在数据库中创建记录,不执行物理文件系统操作。 + parameters: + - name: datasetId + in: path + required: true + schema: + type: string + description: 数据集ID + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddFilesRequest' + responses: + '200': + description: 添加成功,返回创建的文件记录列表 + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/DatasetFileResponse' + /data-management/datasets/{datasetId}/files/upload/pre-upload: post: tags: [ DatasetFile ] @@ -805,3 +834,19 @@ components: path: type: string description: 请求路径 + + AddFilesRequest: + type: object + description: 将源文件路径添加到数据集的请求 + properties: + sourcePaths: + type: array + items: + type: string + description: 源文件路径列表(相对或绝对路径),每个元素表示一个要添加的文件或目录路径 + softAdd: + type: boolean + description: 如果为 true,则仅在数据库中创建记录(默认 false) + default: false + required: + - sourcePaths From bac909109ee6eec4a7733f260534c53327dec02f Mon Sep 17 00:00:00 2001 From: uname <2986773479@qq.com> Date: Wed, 10 Dec 2025 16:29:36 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=E8=AF=84=E4=BC=B0=E6=97=B6=E8=AF=84?= =?UTF-8?q?=E4=BC=B0=E7=BB=93=E6=9E=9C=E8=B5=8B=E4=BA=88=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E7=A9=BA=E5=80=BC=EF=BC=8C=E9=98=B2=E6=AD=A2=E6=9C=AA=E8=AF=84?= =?UTF-8?q?=E4=BC=B0=E5=AE=8C=E6=88=90=E6=97=B6=E6=8E=A5=E5=8F=A3=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datamate-python/app/module/evaluation/service/evaluation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/datamate-python/app/module/evaluation/service/evaluation.py b/runtime/datamate-python/app/module/evaluation/service/evaluation.py index 7af279f94..acfd7866f 100644 --- a/runtime/datamate-python/app/module/evaluation/service/evaluation.py +++ b/runtime/datamate-python/app/module/evaluation/service/evaluation.py @@ -113,6 +113,7 @@ async def save_eval_items(self): file_id=dataset_file.id, item_id=item.get("id") if item.get("id") else str(uuid.uuid4()), eval_content=json.dumps(item, ensure_ascii=False), + eval_result="{}", status=TaskStatus.PENDING.value, created_by=self.task.created_by, updated_by=self.task.updated_by, @@ -152,6 +153,7 @@ async def save_eval_items(self): file_id=synthesis_file.id, item_id=synthesis_data.id, eval_content=json.dumps(synthesis_data.data), + eval_result="{}", status=TaskStatus.PENDING.value, created_by=self.task.created_by, updated_by=self.task.updated_by, From 3796370e1d423fb3d4d121aa9dad45dce900fd99 Mon Sep 17 00:00:00 2001 From: uname <2986773479@qq.com> Date: Wed, 10 Dec 2025 16:31:21 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feature:=20=E6=95=B0=E6=8D=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=94=AF=E6=8C=81=E5=B5=8C=E5=A5=97=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=EF=BC=88=E5=B1=95=E7=A4=BA=E6=97=B6=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=B3=BB=E7=BB=9F=E5=B1=95=E7=A4=BA=EF=BC=9B?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E4=B8=8B=E8=BD=BD=E6=97=B6=E5=B8=A6=E4=B8=8A?= =?UTF-8?q?=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DatasetFileApplicationService.java | 142 +++++++++++++++--- .../rest/DatasetFileController.java | 8 +- .../common/domain/utils/ArchiveAnalyzer.java | 3 +- .../Detail/components/Overview.tsx | 104 ++++++++++++- .../Detail/useFilesOperation.ts | 29 +++- 5 files changed, 248 insertions(+), 38 deletions(-) diff --git a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java index cceb516a0..dcb5422fa 100644 --- a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java +++ b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java @@ -1,6 +1,7 @@ package com.datamate.datamanagement.application; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.datamate.common.domain.model.ChunkUploadPreRequest; import com.datamate.common.domain.model.FileUploadResult; import com.datamate.common.domain.service.FileService; @@ -29,6 +30,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; +import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; @@ -45,12 +49,15 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -85,11 +92,77 @@ public DatasetFileApplicationService(DatasetFileRepository datasetFileRepository */ @Transactional(readOnly = true) public PagedResponse getDatasetFiles(String datasetId, String fileType, String status, String name, PagingQuery pagingQuery) { - IPage page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pagingQuery.getPage(), pagingQuery.getSize()); + IPage page = new Page<>(pagingQuery.getPage(), pagingQuery.getSize()); IPage files = datasetFileRepository.findByCriteria(datasetId, fileType, status, name, page); return PagedResponse.of(files); } + /** + * 获取数据集文件列表 + */ + @Transactional(readOnly = true) + public PagedResponse getDatasetFilesWithDirectory(String datasetId, String prefix, PagingQuery pagingQuery) { + Dataset dataset = datasetRepository.getById(datasetId); + int page = Math.max(pagingQuery.getPage(), 1); + int size = pagingQuery.getSize() == null || pagingQuery.getSize() < 0 ? 20 : pagingQuery.getSize(); + if (dataset == null) { + return PagedResponse.of(new Page<>(page, size)); + } + String datasetPath = dataset.getPath(); + Path queryPath = Path.of(dataset.getPath() + File.separator + prefix); + Map datasetFilesMap = datasetFileRepository.findAllByDatasetId(datasetId) + .stream().collect(Collectors.toMap(DatasetFile::getFilePath, Function.identity())); + try (Stream pathStream = Files.list(queryPath)) { + List allFiles = pathStream + .filter(path -> path.toString().startsWith(datasetPath)) + .sorted(Comparator + .comparing((Path path) -> !Files.isDirectory(path)) + .thenComparing(path -> path.getFileName().toString())) + .collect(Collectors.toList()); + + // 计算分页 + int total = allFiles.size(); + int totalPages = (int) Math.ceil((double) total / size); + + // 获取当前页数据 + int fromIndex = (page - 1) * size; + fromIndex = Math.max(fromIndex, 0); + int toIndex = Math.min(fromIndex + size, total); + + List pageData = new ArrayList<>(); + if (fromIndex < total) { + pageData = allFiles.subList(fromIndex, toIndex); + } + List datasetFiles = pageData.stream().map(path -> getDatasetFile(path, datasetFilesMap)).toList(); + + return new PagedResponse<>(page, size, total, totalPages, datasetFiles); + } catch (IOException e) { + log.error("list dataset path error", e); + return PagedResponse.of(new Page<>(page, size)); + } + } + + private DatasetFile getDatasetFile(Path path, Map datasetFilesMap) { + DatasetFile datasetFile = new DatasetFile(); + LocalDateTime localDateTime = LocalDateTime.now(); + try { + localDateTime = Files.getLastModifiedTime(path).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + } catch (IOException e) { + log.error("get last modified time error", e); + } + datasetFile.setFileName(path.getFileName().toString()); + datasetFile.setUploadTime(localDateTime); + if (Files.isDirectory(path)) { + datasetFile.setId("directory-" + datasetFile.getFileName()); + } else if (Objects.isNull(datasetFilesMap.get(path.toString()))) { + datasetFile.setId("file-" + datasetFile.getFileName()); + datasetFile.setFileSize(path.toFile().length()); + } else { + datasetFile = datasetFilesMap.get(path.toString()); + } + return datasetFile; + } + /** * 获取文件详情 */ @@ -151,15 +224,27 @@ public Resource downloadFile(String datasetId, String fileId) { */ @Transactional(readOnly = true) public void downloadDatasetFileAsZip(String datasetId, HttpServletResponse response) { + Dataset dataset = datasetRepository.getById(datasetId); + if (Objects.isNull(dataset)) { + throw BusinessException.of(DataManagementErrorCode.DATASET_NOT_FOUND); + } List allByDatasetId = datasetFileRepository.findAllByDatasetId(datasetId); + Set filePaths = allByDatasetId.stream().map(DatasetFile::getFilePath).collect(Collectors.toSet()); fileRename(allByDatasetId); + String datasetPath = dataset.getPath(); + Path downloadPath = Path.of(datasetPath); response.setContentType("application/zip"); String zipName = String.format("dataset_%s.zip", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + zipName); - try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) { - for (DatasetFile file : allByDatasetId) { - addToZipFile(file, zos); + try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(response.getOutputStream())) { + try (Stream pathStream = Files.walk(downloadPath)) { + List allPaths = pathStream.filter(path -> path.toString().startsWith(datasetPath)) + .filter(path -> filePaths.stream().anyMatch(filePath -> filePath.startsWith(path.toString()))) + .toList(); + for (Path path : allPaths) { + addToZipFile(path, downloadPath, zos); + } } } catch (IOException e) { log.error("Failed to download files in batches.", e); @@ -167,6 +252,37 @@ public void downloadDatasetFileAsZip(String datasetId, HttpServletResponse respo } } + private void addToZipFile(Path path, Path basePath, ZipArchiveOutputStream zos) throws IOException { + String entryName = basePath.relativize(path) + .toString() + .replace(File.separator, "/"); + + // 处理目录 + if (Files.isDirectory(path)) { + if (!entryName.isEmpty()) { + entryName += "/"; + ZipArchiveEntry dirEntry = new ZipArchiveEntry(entryName); + zos.putArchiveEntry(dirEntry); + zos.closeArchiveEntry(); + } + } else { + // 处理文件 + ZipArchiveEntry fileEntry = new ZipArchiveEntry(path.toFile(), entryName); + + // 设置更多属性 + BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class); + fileEntry.setSize(attrs.size()); + fileEntry.setLastModifiedTime(attrs.lastModifiedTime()); + + zos.putArchiveEntry(fileEntry); + + try (InputStream is = Files.newInputStream(path)) { + IOUtils.copy(is, zos); + } + zos.closeArchiveEntry(); + } + } + private void fileRename(List files) { Set uniqueFilenames = new HashSet<>(); for (DatasetFile file : files) { @@ -188,24 +304,6 @@ private String generateNewFilename(String oldFilename, int counter) { return oldFilename.substring(0, dotIndex) + "-(" + counter + ")" + oldFilename.substring(dotIndex); } - private void addToZipFile(DatasetFile file, ZipOutputStream zos) throws IOException { - if (file.getFilePath() == null || !Files.exists(Paths.get(file.getFilePath()))) { - log.warn("The file hasn't been found on filesystem, id: {}", file.getId()); - return; - } - try (InputStream fis = Files.newInputStream(Paths.get(file.getFilePath())); - BufferedInputStream bis = new BufferedInputStream(fis)) { - ZipEntry zipEntry = new ZipEntry(file.getFileName()); - zos.putNextEntry(zipEntry); - byte[] buffer = new byte[8192]; - int length; - while ((length = bis.read(buffer)) >= 0) { - zos.write(buffer, 0, length); - } - zos.closeEntry(); - } - } - /** * 预上传 * diff --git a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/interfaces/rest/DatasetFileController.java b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/interfaces/rest/DatasetFileController.java index 2a676c08c..1d1a8bfd6 100644 --- a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/interfaces/rest/DatasetFileController.java +++ b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/interfaces/rest/DatasetFileController.java @@ -46,12 +46,10 @@ public Response> getDatasetFiles( @PathVariable("datasetId") String datasetId, @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "size", required = false, defaultValue = "20") Integer size, - @RequestParam(value = "fileType", required = false) String fileType, - @RequestParam(value = "status", required = false) String status, - @RequestParam(value = "name", required = false) String name) { + @RequestParam(value = "prefix", required = false) String prefix) { PagingQuery pagingQuery = new PagingQuery(page, size); - PagedResponse filesPage = datasetFileApplicationService.getDatasetFiles( - datasetId, fileType, status, name, pagingQuery); + PagedResponse filesPage = datasetFileApplicationService.getDatasetFilesWithDirectory( + datasetId, prefix, pagingQuery); return Response.ok(filesPage); } diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/domain/utils/ArchiveAnalyzer.java b/backend/shared/domain-common/src/main/java/com/datamate/common/domain/utils/ArchiveAnalyzer.java index d42c3f240..d3b6e0769 100644 --- a/backend/shared/domain-common/src/main/java/com/datamate/common/domain/utils/ArchiveAnalyzer.java +++ b/backend/shared/domain-common/src/main/java/com/datamate/common/domain/utils/ArchiveAnalyzer.java @@ -12,6 +12,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; +import org.apache.commons.io.FileUtils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -145,7 +146,7 @@ private static Optional extractEntity(ArchiveInputStream ar Path path = Paths.get(archivePath.getParent().toString(), archiveEntry.getName()); File file = path.toFile(); long fileSize = 0L; - String extension = AnalyzerUtils.getExtension(archiveEntry.getName()); + FileUtils.createParentDirectories(file); long supportFileSize = 1024*1024*1024; // 上传大小暂定为1个G try (OutputStream outputStream = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) { diff --git a/frontend/src/pages/DataManagement/Detail/components/Overview.tsx b/frontend/src/pages/DataManagement/Detail/components/Overview.tsx index 85900acc9..5d7631278 100644 --- a/frontend/src/pages/DataManagement/Detail/components/Overview.tsx +++ b/frontend/src/pages/DataManagement/Detail/components/Overview.tsx @@ -1,6 +1,6 @@ import { Button, Descriptions, DescriptionsProps, Modal, Table } from "antd"; import { formatBytes, formatDateTime } from "@/utils/unit"; -import { Download, Trash2 } from "lucide-react"; +import { Download, Trash2, Folder, File } from "lucide-react"; import { datasetTypeMap } from "../../dataset.const"; export default function Overview({ dataset, filesOperation, fetchDataset }) { @@ -102,13 +102,58 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) { dataIndex: "fileName", key: "fileName", fixed: "left", + render: (text: string, record: any) => { + const isDirectory = record.id.startsWith('directory-'); + const iconSize = 16; + + const content = ( +
+ {isDirectory ? ( + + ) : ( + + )} + {text} +
+ ); + + if (isDirectory) { + return ( + + ); + } + + return ( + + ); + }, }, { title: "大小", dataIndex: "fileSize", key: "fileSize", width: 150, - render: (text) => formatBytes(text), + render: (text: number, record: any) => { + const isDirectory = record.id.startsWith('directory-'); + if (isDirectory) { + return "-"; + } + return formatBytes(text) + }, }, { title: "上传时间", @@ -122,7 +167,12 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) { key: "action", width: 180, fixed: "right", - render: (_, record) => ( + render: (_, record) => { + const isDirectory = record.id.startsWith('directory-'); + if (isDirectory) { + return
; + } + return (
- ), + )}, }, ]; + return ( <>
@@ -182,6 +233,43 @@ export default function Overview({ dataset, filesOperation, fetchDataset }) {
)}
+
+ {(filesOperation.pagination.prefix || '') !== '' && ( + + )} + {filesOperation.pagination.prefix && ( + 当前路径: {filesOperation.pagination.prefix} + )} +
`共 ${total} 条`, + onChange: (page, pageSize) => { + filesOperation.setPagination(prev => ({ + ...prev, + current: page, + pageSize: pageSize + })); + filesOperation.fetchFiles(pagination.prefix, page, pageSize); + } }} /> diff --git a/frontend/src/pages/DataManagement/Detail/useFilesOperation.ts b/frontend/src/pages/DataManagement/Detail/useFilesOperation.ts index 5d6e2a139..40d772674 100644 --- a/frontend/src/pages/DataManagement/Detail/useFilesOperation.ts +++ b/frontend/src/pages/DataManagement/Detail/useFilesOperation.ts @@ -23,19 +23,35 @@ export function useFilesOperation(dataset: Dataset) { current: number; pageSize: number; total: number; - }>({ current: 1, pageSize: 10, total: 0 }); + prefix?: string; + }>({ current: 1, pageSize: 10, total: 0, prefix: '' }); // 文件预览相关状态 const [previewVisible, setPreviewVisible] = useState(false); const [previewContent, setPreviewContent] = useState(""); const [previewFileName, setPreviewFileName] = useState(""); - const fetchFiles = async () => { - const { data } = await queryDatasetFilesUsingGet(id!, { - page: pagination.current - 1, - size: pagination.pageSize, - }); + const fetchFiles = async (prefix: string = '', current, pageSize) => { + const params: any = { + page: current ? current : pagination.current, + size: pageSize ? pageSize : pagination.pageSize, + }; + + if (prefix !== undefined) { + params.prefix = prefix; + } else if (pagination.prefix) { + params.prefix = pagination.prefix; + } + + const { data } = await queryDatasetFilesUsingGet(id!, params); setFileList(data.content || []); + + // Update pagination with current prefix + setPagination(prev => ({ + ...prev, + prefix: prefix !== undefined ? prefix : prev.prefix, + total: data.totalElements || 0, + })); }; const handleBatchDeleteFiles = () => { @@ -113,6 +129,7 @@ export function useFilesOperation(dataset: Dataset) { fileList, selectedFiles, setSelectedFiles, + pagination, setPagination, previewVisible, setPreviewVisible, From 98e24b39bed8e4559aaf068d8a75d7be141396ca Mon Sep 17 00:00:00 2001 From: uname <2986773479@qq.com> Date: Wed, 10 Dec 2025 16:32:58 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E9=87=8D=E5=91=BD=E5=90=8D=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DatasetFileApplicationService.java | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java index dcb5422fa..22fafbd58 100644 --- a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java +++ b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java @@ -230,7 +230,6 @@ public void downloadDatasetFileAsZip(String datasetId, HttpServletResponse respo } List allByDatasetId = datasetFileRepository.findAllByDatasetId(datasetId); Set filePaths = allByDatasetId.stream().map(DatasetFile::getFilePath).collect(Collectors.toSet()); - fileRename(allByDatasetId); String datasetPath = dataset.getPath(); Path downloadPath = Path.of(datasetPath); response.setContentType("application/zip"); @@ -283,27 +282,6 @@ private void addToZipFile(Path path, Path basePath, ZipArchiveOutputStream zos) } } - private void fileRename(List files) { - Set uniqueFilenames = new HashSet<>(); - for (DatasetFile file : files) { - String originalFilename = file.getFileName(); - if (!uniqueFilenames.add(originalFilename)) { - String newFilename; - int counter = 1; - do { - newFilename = generateNewFilename(originalFilename, counter); - counter++; - } while (!uniqueFilenames.add(newFilename)); - file.setFileName(newFilename); - } - } - } - - private String generateNewFilename(String oldFilename, int counter) { - int dotIndex = oldFilename.lastIndexOf("."); - return oldFilename.substring(0, dotIndex) + "-(" + counter + ")" + oldFilename.substring(dotIndex); - } - /** * 预上传 * From 43cb7604eb13aae3b378b8f0234e84c908bf585d Mon Sep 17 00:00:00 2001 From: uname <2986773479@qq.com> Date: Wed, 10 Dec 2025 16:39:19 +0800 Subject: [PATCH 6/6] refactor: remove unused imports --- .../application/DatasetFileApplicationService.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java index 22fafbd58..02aaf546a 100644 --- a/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java +++ b/backend/services/data-management-service/src/main/java/com/datamate/datamanagement/application/DatasetFileApplicationService.java @@ -41,7 +41,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -58,8 +57,6 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; /** * 数据集文件应用服务