From 67f30d793d9a0854d1b7eda1a76dc1b5296a7b20 Mon Sep 17 00:00:00 2001 From: liujun Date: Mon, 26 Feb 2024 18:26:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=8E=8B=E7=BC=A9=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/zcloud/util/Warden.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zcloud/util/Warden.java b/src/main/java/com/zcloud/util/Warden.java index 701953a5..eb23c46b 100644 --- a/src/main/java/com/zcloud/util/Warden.java +++ b/src/main/java/com/zcloud/util/Warden.java @@ -373,10 +373,15 @@ public class Warden { FileInputStream fileInputStream; ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); try (ZipOutputStream zipOut = new ZipOutputStream(byteOutStream)) { - + String fileNames = ""; + Random random = new Random(); for (File file : srcFiles) { fileInputStream = new FileInputStream(file); - ZipEntry zipEntry = new ZipEntry(file.getName()); + String fileName = file.getName(); + if (fileNames.contains(fileName)){ + fileName = (random.nextInt(90000) + 10000) + fileName; + } + ZipEntry zipEntry = new ZipEntry(fileName); zipOut.putNextEntry(zipEntry); int len; byte[] buffer = new byte[1024];