CompressUtil.createExtractor支持tgz自动识别

This commit is contained in:
Looly 2024-07-31 00:36:13 +08:00
parent 1cb0ec327d
commit c6fc880405
2 changed files with 8 additions and 3 deletions

View File

@ -15,6 +15,7 @@
* 【poi 】 增加GlobalPoiConfigissue#IAEHJH@Gitee
* 【core 】 优化IndexedComparator性能pr#1240@Gitee
* 【http 】 改进ContentType.get忽略空格pr#3664@Github
* 【http 】 CompressUtil.createExtractor支持tgz自动识别pr#3674@Github
### 🐞Bug修复
* 【core 】 修复因RFC3986理解有误导致的UrlPath处理冒号转义问题issue#IAAE88@Gitee

View File

@ -170,12 +170,16 @@ public class CompressUtil {
if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(archiverName)) {
return new SevenZExtractor(file);
}
try {
if (StrUtil.isBlank(archiverName) && file.getName().toLowerCase().endsWith(".tgz")) {
if(StrUtil.isBlank(archiverName)){
final String name = file.getName().toLowerCase();
if(name.endsWith(".tgz")){
archiverName = "tgz";
} else if (StrUtil.isBlank(archiverName) && file.getName().toLowerCase().endsWith(".tar.gz")) {
} else if(name.endsWith(".tar.gz")){
archiverName = "tar.gz";
}
}
try {
return new StreamExtractor(charset, archiverName, file);
} catch (CompressException e) {
final Throwable cause = e.getCause();