mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix Archiver 最后一个 Entry 为空文件夹时未关闭 Entry
This commit is contained in:
parent
c61946650e
commit
c359a547cf
@ -177,6 +177,8 @@ public class StreamArchiver implements Archiver {
|
||||
for (File childFile : files) {
|
||||
addInternal(childFile, entryName, filter);
|
||||
}
|
||||
} else {
|
||||
out.closeArchiveEntry();
|
||||
}
|
||||
} else {
|
||||
if (file.isFile()) {
|
||||
|
@ -72,4 +72,36 @@ public class ArchiverTest {
|
||||
})
|
||||
.finish().close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add: D:\disk-all
|
||||
* Add: D:\disk-all\els-app
|
||||
* Add: D:\disk-all\els-app\db-backup
|
||||
* Add: D:\disk-all\els-app\新建 文本文档.txt
|
||||
* Add: D:\disk-all\新建 文本文档.txt
|
||||
* Add: D:\disk-all\新建文件夹
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void emptyTest(){
|
||||
final File file = FileUtil.file("d:/disk-all.tgz");
|
||||
CompressUtil.createArchiver(CharsetUtil.CHARSET_UTF_8, "tgz", file)
|
||||
.add(FileUtil.file("D:\\disk-all"), (f)->{
|
||||
Console.log("Add: {}", f.getPath());
|
||||
return true;
|
||||
})
|
||||
.finish().close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void emptyZTest(){
|
||||
final File file = FileUtil.file("d:/disk-all.7z");
|
||||
CompressUtil.createArchiver(CharsetUtil.CHARSET_UTF_8, "7z", file)
|
||||
.add(FileUtil.file("D:\\disk-all"), (f)->{
|
||||
Console.log("Add: {}", f.getPath());
|
||||
return true;
|
||||
})
|
||||
.finish().close();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user