mirror of
https://gitee.com/dromara/hutool.git
synced 2025-06-28 13:34:09 +08:00
fix bug
This commit is contained in:
parent
a6d4e96a41
commit
ac11df0889
@ -26,6 +26,7 @@
|
|||||||
* 【core 】 修复IterUtil.filter无效问题
|
* 【core 】 修复IterUtil.filter无效问题
|
||||||
* 【core 】 修复NumberUtil传入null,返回了true(issue#I5DTSL@Gitee)
|
* 【core 】 修复NumberUtil传入null,返回了true(issue#I5DTSL@Gitee)
|
||||||
* 【core 】 修复NumberUtil.isDouble问题(pr#2400@Github)
|
* 【core 】 修复NumberUtil.isDouble问题(pr#2400@Github)
|
||||||
|
* 【core 】 修复ZipUtil使用append替换文件时,父目录存在报错问题(issue#I5DRU0@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.CopyOption;
|
import java.nio.file.CopyOption;
|
||||||
|
import java.nio.file.DirectoryNotEmptyException;
|
||||||
import java.nio.file.FileAlreadyExistsException;
|
import java.nio.file.FileAlreadyExistsException;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
@ -48,10 +49,13 @@ public class ZipCopyVisitor extends SimpleFileVisitor<Path> {
|
|||||||
// 在目标的Zip文件中的相对位置创建目录
|
// 在目标的Zip文件中的相对位置创建目录
|
||||||
try {
|
try {
|
||||||
Files.copy(dir, targetDir, copyOptions);
|
Files.copy(dir, targetDir, copyOptions);
|
||||||
|
} catch (final DirectoryNotEmptyException ignore) {
|
||||||
|
// 目录已经存在,则跳过
|
||||||
} catch (FileAlreadyExistsException e) {
|
} catch (FileAlreadyExistsException e) {
|
||||||
if (false == Files.isDirectory(targetDir)) {
|
if (false == Files.isDirectory(targetDir)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
// 目录非空情况下,跳过创建目录
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package cn.hutool.core.compress;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ZipUtil;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
|
public class IssueI5DRU0Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void appendTest(){
|
||||||
|
// https://gitee.com/dromara/hutool/issues/I5DRU0
|
||||||
|
// 向zip中添加文件的时候,如果添加的文件的父目录已经存在,会报错。实际中目录存在忽略即可。
|
||||||
|
ZipUtil.append(Paths.get("d:/test/zipTest.zip"), Paths.get("d:/test/zipTest"), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user